Time for action — combining user control and animation
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() ...
Get Ogre 3D 1.7 now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.