- Home /
AI Animation Relative to its Forward Direction
I have an AI that constantly rotates to look at the player, it also has a NavMeshAgent attached and moves around the navmesh. I'm unable to figure out how to make the AI play the proper animation relative to its forward direction when moving. For example, the AI is aiming at the player and moving left, i want the AI to do the walk left animation based on its relative forward direction, similar to AI in games like mass effect 1, 2 and 3.
I use a blend tree and I assumed setting the animator controllers velx and vely parameters to the navMeshAgent.velocity.x and navMeshAgent.velocity.y but this resulted in unfavorable results...
any help is appreciated :)
Answer by Fibonacci_0_1_1 · Aug 31, 2020 at 05:40 PM
partly solved by using moveDir = transform.InverseTransformDirection(moveDir ); and instead of using velocityY, I used velocityX & velocityZ.
now the only problem is when the player is directly in front of the agent and the agent is moving in a 45 degree angle, there is a slow transition from forward animation to diagonal.