- Home /
Answer by aldonaletto · Dec 19, 2011 at 02:09 PM
You can use a coroutine: it runs "behind the scenes" in the update cycle, but not in the Update function (coroutines are forbidden inside Update). You could also use FixedUpdate - a better solution if the object is a rigidbody driven by forces.
Unfortunately, the docs don't have good examples on this. You can take a look at the question
Smooth Object Movement, where a coroutine is used to move a zoombie.
Answer by caret- · Dec 19, 2011 at 04:49 PM
What is it you are after?
Could you start a co-routine that does the movement for you? (search: StartCoroutine). Lets say you create a function called "Move". Just have a loop (while/for) in your "Move"-function that moves your object. In the end of the loop put a yield; so it will wait for the next frame. Then just add a check where you break from the loop when the movement is done.
Now you can call the "move"-function from anywhere and you are not using the Update-function..