Search Unity

What does Animator.deltaPosition return?

Discussion in 'Animation' started by Deleted User, May 20, 2020.

  1. Deleted User

    Deleted User

    Guest

    I am reading https://learn.unity.com/tutorial/pl...65ddedbc2a08d53c7acb#5caf7217edbc2a08d53c87f0
    and there is a method:
    Code (CSharp):
    1.     void OnAnimatorMove ()
    2.     {
    3.         m_Rigidbody.MovePosition (m_Rigidbody.position + m_Movement * m_Animator.deltaPosition.magnitude);
    4.         m_Rigidbody.MoveRotation (m_Rotation);
    5.     }
    I think, this method is to change the location of the character, but what does
    m_Animator.deltaPosition
    return?

    It is said that it "Gets the avatar delta position for the last evaluated frame.", but the position doesn't change, so does it return zero?

    The reason why the position doesn't change is that the
    OnAnimatorMove ()
    method is to change the character's location as mentioned above, so
    m_Animator.deltaPosition
    cannot also change the location, because you cannot change the location twice, is that correct?

    In general, does Animator change location of the game object to which it is attached?

    In my opinion, for example, Animator only moves the arms and legs of a character, but never changes the location of the character as a whole, is that right?

    Thanks!
     
  2. kamran-bigdely

    kamran-bigdely

    Joined:
    Jun 19, 2014
    Posts:
    25
    m_Animator.deltaPosition returns the character movement that the artist has designed in the walking animation. So if the artist has made the walking animation such that the character walks on the spot, deltaPositin returns zero.

    Watch the animation clip in Unity and see whether your character actually moves its position (and not just moving its body part faking walking forward).

    To fix it, you would have to open the animation file in Blender or may and modified it there.
     
    vikramjayapal2391999 likes this.