And, as always, we will use the previous code as a starting point:
Firstly, we need two new variables in the
FrameListener
for controlling the movement speed and saving our rotation:float _WalkingSpeed; float _rotation;
In the constructor, we init the new values; we want to move at 50 units per second and start with no rotation:
_WalkingSpeed = 50.0f; _rotation = 0.0f;
Then we need to change our animation states to prevent them from looping. This time, we are going to control when a new animation has to start and not Ogre 3D:
_aniState = _ent->getAnimationState("RunBase"); _aniState->setLoop(false); _aniStateTop = _ent->getAnimationState("RunTop"); _aniStateTop->setLoop(false);
In the
frameStarted()
method, we need two new local variables, one to indicate if we have moved our model for this frame and a second one to store the direction in which we have moved our model.bool walked = false; Ogre::Vector3 SinbadTranslate(0,0...