x


How do i loop my script so it continuously does what is inside it?

Possible Duplicate:
How to go from the bottom of your script back to the top in game?

function Start () {
    iTween.moveTo(gameObject, {"z":-11.5, "time": 2, "transition":"easeInOutExpo", "onComplete":"Rotate1" });       
}

function Rotate1(){
    iTween.rotateTo(gameObject, {"x":180, "time": 2, "onComplete": "MoveBack"});
}

function MoveBack() {
     iTween.moveTo(gameObject, { "z":-4.5, "time": 2, "transition":"easeInOutExpo", "onComplete": "Rotate2"} );
}

function Rotate2(){
iTween.rotateTo(gameObject, {"x":-180, "time": 2});
}

I want it to go from the end of

more ▼

asked Jun 28 '10 at 12:08 PM

Daniel 8 gravatar image

Daniel 8
71 13 15 24

Not really straight forward. Actually makes no sense.

What do you mean? I read this as "My script is in use and I want to get it back to the top" The top of what? You don't move scripts, what is the script?

Jun 28 '10 at 12:44 PM Murcho

All i want is it do read my script, which has it doing 3 animations and then when it gets to the last animation go back up to the top and start all 3 animations again. And the top of what? The top of the script.

Jun 28 '10 at 01:23 PM Daniel 8

You could start by quoting your script in your question so that it is possible to understand what you are asking about. You can snip most of the animations to keep the size manageable

Jun 28 '10 at 02:21 PM Stanislav Pugach

@Daniel, please don't post duplicate Questions - if you don't understand the Answer, edit your original Question or post a comment to the Answer.

Jun 28 '10 at 03:48 PM Cyclops
(comments are locked)
10|3000 characters needed characters left

2 answers: sort newest

You need to chain iTweens with the delay property. Please take a look at the hello world complex example I have provided on the support page.

more ▼

answered Jul 19 '10 at 05:20 AM

pixelplacement gravatar image

pixelplacement
682 8

(comments are locked)
10|3000 characters needed characters left

Sounds like you want a loop. This is similar, almost identical to the system used by the AI in the FPS tutorial.

//JS
function Start() {
    RepeatLoop ();
}

function RepeatLoop () {
    while(true) {
       //do all your animation stuff here.
       //you might have to use coroutines to yield the result.

       yield;
    }
}
more ▼

answered Jun 28 '10 at 01:29 PM

Peter G gravatar image

Peter G
15k 16 44 136

it says i need to add a : instead of a ; but then i get 4 more errors? This just doesnt make sense!

Jun 29 '10 at 01:47 AM Daniel 8
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x168
x122

asked: Jun 28 '10 at 12:08 PM

Seen: 1059 times

Last Updated: Jul 19 '10 at 08:23 AM