i need help to make my character running.
This is not the whole script.
if i press input button run the character must go to run state.
but the character didn’t do it.
public void DetermineCurrentMoveDirection()
{
var forward = false;
var backward = false;
var left = false;
var right = false;
var Run = false;
if (Input.GetButtonDown("Run"))
Run = true;
if (TP_Motor.Instance.MoveVector.z > 0)
forward = true;
if (TP_Motor.Instance.MoveVector.z < 0)
backward = true;
if (TP_Motor.Instance.MoveVector.x > 0)
right = true;
if (TP_Motor.Instance.MoveVector.x < 0)
left = true;
if (forward)
{
if (left)
MoveDirection = Direction.LeftForward;
else if (right)
MoveDirection = Direction.RightForward;
else
MoveDirection = Direction.Forward;
}
else if (backward)
{
if (left)
MoveDirection = Direction.LeftBackward;
else if (right)
MoveDirection = Direction.RightBackward;
else
MoveDirection = Direction.Backward;
}
else if (Run)
{
MoveDirection = Direction.Run;
forward = false;
Run = true;
}
else if (left)
{
MoveDirection = Direction.Left;
}
else if (right)
{
MoveDirection = Direction.Right;
}
else
{
MoveDirection = Direction.Stationary;
}
}
and I would really like that the character a number of seconds can run and that it then need to recharge a few seconds.
I hope someone could help me also with this.