O'Reilly logo

Ogre 3D 1.7 by Felix Kerger

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Time for action — combining user control and animation

And, as always, we will use the previous code as a starting point:

  1. Firstly, we need two new variables in the FrameListener for controlling the movement speed and saving our rotation:
    float _WalkingSpeed;
    float _rotation;
    
  2. 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;
    
  3. 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);
    
  4. In the frameStarted() ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required