- Home /
How do I rest an gameobject that has an animation on it?
I have a gameobject (button) that has an animation on it. That animation simply moves the object (Button being pressed). This is triggered at some point in the game. Now I need to reset the gameobject to its original position? How? From all my tests I have determined that the gameobject doesn't really know where it is at, it is the animation that determines its location.
What happens is when I Play the animation again, the first frame moves it to the first frame location (correct original location).
Thoughts? (Thanks)
Answer by vbbartlett · Jan 10, 2013 at 04:53 PM
I have found two methods to Reset a GameObject, First create a Parent GO and then place the animating GO under it such that its position/rotation are zero, then reset simply reset these values, while the parent holds the original position and rotation. Second, call a coroutine which simply Play();Yield();Stop(); This will locate the GO to the position in the first frame. This works if the animation has the first frame in the correctly start location.
hope this helps someone
Your answer
Follow this Question
Related Questions
Syncing object's coordinate position with object's animation position. 3 Answers
Reset and Play Animation using UI Buttons - Replay Button 0 Answers
Unity 3 Animation Positioning Problem 1 Answer
set child object position when playing the animation 0 Answers
Resetting a position after reaching a certain point 2 Answers