Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Animation not working as expected?

Discussion in 'Animation' started by Skyvastern, Apr 17, 2020.

  1. Skyvastern

    Skyvastern

    Joined:
    Nov 23, 2018
    Posts:
    6
    So to represent this problem into it's most basic form, I do the following in a new scene -

    • Create a new 3D cube
    • Add an animator component to it
    • Make an animation of 1 second where the start and end frames have a rotation of the cube set to (0, 0, 0) in the inspector. So that way cube won't rotate when in play mode.
    • Then create a new script, and inside the Update loop just add the following line -
    transform.Rotate(45 * Time.deltaTime, 0, 0)

    ( it can be any angle, or any other way we can rotate the cube )

    Then when I run the game, it turns out the cube is actually rotating. And that's the thing I don't understand. Because isn't it that the Update frame runs before the animation frames. According to -

    https://docs.unity3d.com/Manual/ExecutionOrder.html

    And in order to make this thing true, if I just change the end keyframe to say something else, just different than the beginning frame, then the Update loop should not work.

    What I am doing wrong here? I don't get it. Btw my actual problem is something else but related to it only, but upon debugging my problem I came to know about this. I don't quite get it, what is actually happening here?