- Home /
Playing animations by velocity for the correct direction.
Worked on the script and got some progress so changed question to what I am dealing with now.
So I have a script for setting the animations by the velocity of the Rigidbody. This works fantastic. But now I am trying to overcome of what to do when the transform is rotated so the velocity's are changed between X and Z.
MY QUESTION IS: Is there another better way to do this? Am I going at this all wrong? If not...
Ok, my script works every where expect getting the Strafing animations to play correctly.
Running Code
if(rigidbody.velocity.z <= -0.1f && rigidbody.velocity.x >= -4.7f && transform.eulerAngles.y >= 80 && transform.eulerAngles.y <= 180)
{
characterModel.animation.CrossFade("Run");
}
Strafing Code
if(rigidbody.velocity.x >= 0.1f && rigidbody.velocity.z <= 4.5f && transform.eulerAngles.y >= 0 && transform.eulerAngles.y <= 88)
{
characterModel.animation.CrossFade("StrafeRunRight");
}
Basically what I am thinking is that I need something else that I could reference for when I am strafing. Since both running and strafing effect both X and Z when the transform is rotated.
I just can't think of what to do next. Any help would be appreciated. :)
Your answer
Follow this Question
Related Questions
Play different animations based on direction character is facing, while following the mouse. 1 Answer
Can I make animations snap to a frame? 1 Answer
Objects rotate but remain on the original axis... 0 Answers
Change characters direction using camera view 0 Answers
How to rotate spine by the script, while an animation from the animator is playing? 0 Answers