O'Reilly logo

Panda3D 1.6 Game Engine by Dave Mathews

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

Using delta time

Within video games, it's rarely a good idea to have continuous actions, such as movement, use a static value every frame. For instance, we have our cycle moving 0.1 units per frame, so if our frame rate is 60, the cycle will move 6 units per second. If our frame rate is 30, our cycle will move 3 units per second. What we want is to have our cycle move at a constant speed, regardless of the frame rate. We can achieve that by using delta time.

Delta time means change in time. In our case, delta time will be the change in time from the last frame to the current frame. We can get delta time from the globalClock object using the method getDt. Fortunately, DirectStart creates the globalClock object for us, so we don't need to worry ...

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