Animator deltaPosition

I’m using a NavMeshAgent to move my character forward and I’m using

agent.speed = (animator.deltaPosition / Time.deltaTime).magnitude;

to set the speed.

It works reasonable well for walks that don’t have a lot of side to side movement, but some of my animations do have a lot of left and right movement of the walk so I want to fix it in code.

Since the agent is handling the forward movement, how can I move the transform.positon of the character only left or right, without moving it forward, based on the animator.deltaPosition?

@FiveFingerStudios you should change the agent velocity instead. Put this inside the OnAnimatorMove() :

agent.velocity = animator.deltaPosition / Time.deltaTime;

This way you don’t need to set your agent’s speed, as it move using animation

Edit: you will need a variable to control your animation, maybe something like calculating distance from the agent to destination, and use it to set your animation parameter