Time for action — adding time-based movement

We will use the previously used code and only modify one line of code:

  1. Change the line where we translate the node to:
    _node->translate(Ogre::Vector3(10,0,0) * evt.timeSinceLastFrame);
    
  2. Compile and run the application. You should see the same scene as before, only the model might move at a different speed.

What just happened?

We changed our movement model from frame-based to time-based. We achieved this by adding a simple multiplication. As said before, frame-based movement has some downfalls. Time-based movement is simply superior because we get the same movement on all computers and have much more control over the movement speed. In step 1, we used the fact that Ogre 3D passes a FrameEvent when calling ...

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.