- Home /
This post has been wikified, any user with enough reputation can edit it.
Question by
JuanseCoello · Jul 24, 2013 at 09:51 PM ·
rotateaxisvectorrotatearound
Make a Move Vector rotate around axis to run animation.
My character can move Vertically and sideways. And it also can rotate around its axis. But when it rotates around its axis I want the ANIMATION class, to recognize the rotation to play the animations: TurningRight and TurningLeft.
Here is the script:
public void DetermineCurrentMoveDirection()
{
var turningright = false;
var turningleft = false;
if (TP_Motor.Instance.MoveVector.y > 0) // This is the important part that should be changed
turningright = true;
if (TP_Motor.Instance.MoveVector.y < 0) // This is the important part 2
turningleft = true;
BUT HOW CAN I CONVERT THE = MoveVector.y, to a rotation???
// Turning
if (turningright)
{
if (turningright)
MoveDirection = Direction.TurningRight;
}
if (turningleft)
{
if (turningleft)
MoveDirection = Direction.TurningLeft;
}
#region Character State Methods
void TurningLeft()
{
animation.CrossFade("TurningLeft");
}
void TurningRight()
{
animation.CrossFade("TurningRight");
}
#endregion
}
In other words, how can I convert a vector to rotate around its axis, and how to make the script recognize that movement to play an animation.
What I did is to recognize the imput keys, but i dont recommend it. Here is the second code:
if (!Input.GetKey(KeyCode.LeftShift) && Input.GetKey("d") && !Input.GetKey(KeyCode.CapsLock)
&& !Input.GetKey("w") && !Input.GetKey("up") && !Input.GetKey("down") ||
!Input.GetKey(KeyCode.LeftShift) && Input.GetKey("right") && !Input.GetKey(KeyCode.CapsLock)
&& !Input.GetKey("w") && !Input.GetKey("up") && !Input.GetKey("down"))
turningright = true;
Comment
Your answer
Follow this Question
Related Questions
Snap the rotation of object 2 Answers
rotate object around another object 1:1 1 Answer
RotateAround 2 axes at once 0 Answers