- Home /
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
Not really straight forward. Actually makes no sense.
What do you mean? I read this as "$$anonymous$$y 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?
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.
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
@$$anonymous$$, please don't post duplicate Questions - if you don't understand the Answer, edit your original Question or post a comment to the Answer.
Answer by Peter G · Jun 28, 2010 at 01:29 PM
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;
}
}
it says i need to add a : ins$$anonymous$$d of a ; but then i get 4 more errors? This just doesnt make sense!
Answer by pixelplacement · Jul 19, 2010 at 05:20 AM
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.
Your answer
Follow this Question
Related Questions
Where can I learn to script in Unity? 1 Answer
Ground Plane when starting new project 1 Answer
unity text -- 1 Answer
How to make a "cinematic" Intro 1 Answer
frame only 0 Answers