- Home /
Getting turning direction for character without using Input
I want to assign different animations to my character when he is walking and turning left/right.
My problem is that I'm using a NavMeshAgent so I cant get the Input values from the keyboard to know how much he is turning or not. How could I find it via scripting?
Thanks in advance!
Comment
Best Answer
Answer by castor · Mar 22, 2013 at 07:40 PM
Found the answer, here it is if anyone is interested:
function Start () {
lastFrameAngle = actorParent.eulerAngles.y;
}
function CalculateDirection(){ //running it on Update
var currentFrameAngle : float = actorParent.eulerAngles.y;
angleDifference = currentFrameAngle - lastFrameAngle;
lastFrameAngle = currentFrameAngle;
}