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

Question How to make the animation turn to the player?

Discussion in 'Navigation' started by NewMagic-Studio, Jul 5, 2020.

  1. NewMagic-Studio

    NewMagic-Studio

    Joined:
    Feb 25, 2015
    Posts:
    454
    I am using

    agent.destination = playerGroundPos;
    animator.SetFloat("Speed", agent.desiredVelocity.magnitude, 0.05f, Time.deltaTime);
    animator.SetFloat("Rotation", Vector3.SignedAngle(agent.desiredVelocity, transform.forward, Vector3.up), 0.05f, Time.deltaTime);

    but doesnt work, any ideas?

    tried also
    animator.SetFloat("Rotation", Mathf.Atan2(relVelocity.x, relVelocity.z), 0.05f, Time.deltaTime);