- Home /
The animated object returns to its initial state
I have an object (a simple card) equipped with the Rigidbody, Collider and Animator components. In particular, Animator performs a simple clip that rotates the card 180 degrees.
So the clip should cover or uncover the card. The problem is that the card returns to its original state.
For example, when the card is uncovered, I click on it to cover and it covers as expected. However, immediately after the animation ends, it returns to its original state (uncovered). What should I do to leave it covered? Should I create two different animations? One to cover and the other to uncover and then managing the states of the animations with the blocks and arrows?
A full detailed question can be found here.
Answer by _samuel12345 · Jun 04, 2018 at 10:38 AM
Try waiting until the animation has finished playing and then setting the card's rotation to whatever it was at the end of the animation. Try this:
if (this.animator.GetCurrentAnimatorStateInfo(0).IsName("YourAnimationName")) {
transform.rotation = Quaternion.Euler(0, 180, 0);
}