Implement turning states

actorid
Chris Robinson 12 years ago
parent 7611caa6eb
commit 4836ba16f7

@ -75,6 +75,9 @@ static const struct {
{ CharState_SneakLeft, "sneakleft" },
{ CharState_SneakRight, "sneakright" },
{ CharState_TurnLeft, "turnleft" },
{ CharState_TurnRight, "turnright" },
{ CharState_Jump, "jump" },
{ CharState_Death1, "death1" },
@ -231,6 +234,13 @@ void CharacterController::update(float duration, Movement &movement)
// Apply any sideways movement manually
movement.mPosition[0] += vec.x * (speed*duration);
}
else if(rot.z != 0.0f && !inwater && !sneak)
{
if(rot.z > 0.0f)
setState(CharState_TurnRight, true);
else if(rot.z < 0.0f)
setState(CharState_TurnLeft, true);
}
else if(mAnimQueue.size() == 0)
setState((inwater ? CharState_IdleSwim : (sneak ? CharState_IdleSneak : CharState_Idle)), true);

@ -54,6 +54,9 @@ enum CharacterState {
CharState_SneakLeft,
CharState_SneakRight,
CharState_TurnLeft,
CharState_TurnRight,
CharState_Jump,
/* Death states must be last! */

Loading…
Cancel
Save