1

In my project, I am using the ThirdPersonController that I imported from Unity's Standard Assets. I also have the ThirdPersonAnimatorController for the Ethan Figure. I set up a NavMesh in my scene and created an Ethan GameObject with the Animator and NavMeshAgent. So far, the NavMeshAgent works fine but I want the movement to be synchronized with the animations.

I don't know much about blend trees but I do know that you can set parameters in the script to control the animations. In this case, the ThirdPersonAnimatorController has two parameters, turn and forward (both are floats from 0 to 1 representing the angle of turn and movement speed). So the blend tree is a 2D Freeform Cartesian.

The only problem I have is getting the values from the NavMeshAgent (such as the turn speed and movement speed) so I can pass it into the blend tree.

derHugo
  • 83,094
  • 9
  • 75
  • 115
Jsbbvk
  • 180
  • 2
  • 19

1 Answers1

0

You can use the velocity.magnitude of the NavMeshAgent:

        float speed = GetComponent<NavMeshAgent>().velocity.magnitude;

You could then use a Debug.Log statement to try and divide it by a certain value so you get a number in a certain range, or just use the plain magnitude and change your Animator Controller values.

CodingGuy
  • 71
  • 7