Jump to content
  • Advertisement
Sign in to follow this  

FPS Camera with Fixed Timestep System

This topic is 5185 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi all! I am using a fixed timestep game loop like this one:
time0 = getTime();

Run() {

    time1 = getTime();

    int numLoops = 0;

    while((time1 - time0) > tickTime && numLoops < maxNumTickUpdates) {
        time0 += tickTime;

    if((time1 - time0) > tickTime) {
        time0 = time1 - tickTime;


    float interpolationValue = (time1 - time0) / tickTime;

    return 1;

I am experimenting with fixed timestep but i cant get a smooth camera for it. In every game tick i ProcessInput, in which i update my player's position and orientation, so lets assume my player is defined as player(vector position, vector orientation). This orientation is the N vector of a UVN system. You know that with just N we can compute V and U from it (assuming we have a defined up referencial, normally (0,1,0)). So when i render i interpolate between the last two computated player position/orientation values doing the following:
playerPosition = LERP(oldPlayerPosition, currentPlayerPosition, interpolationValue)

playerOrientation = SLERP(oldPlayerOrientation, currentPlayerOrientation, interpolationValue)

So my camera is positioned at player's position with its orientation. Its not as smooth as it is with a variable time step system. I wanted to hear from anyone if theres a better way to make a FPS camera with fixed time step system. One thing to remember is that in FPS games the camera is indirectly part of the game logic governed by the game tick, because its plugged at the players position and orientation. This doesnt happen with other games in which the camera is free, for example, RTS games. What i mean is, you dont need determinism in a RTS's camera. It doesnt matter where the player had its camera while replaying a game in War3 for example. SO you could have it not governed by the fixed time step. Does anyone know how the camera works in Doom 3? If i am not wrong, Doom 3 uses a fixed time step model with 60hz for the game tick. [Edited by - thun on July 31, 2005 2:18:35 AM]

Share this post

Link to post
Share on other sites
In an FPS game you shouldn't base the camera orientation on the player orientation, but the other way around. The camera should always respond instantly as you move your mouse, and the player entity's orientation (if any) will then follow the camera's. Since you can't usually see yourself this only affects multiplayer games... In a single player game you don't even need a specific player entity orientation if the code for firing weapons etc knows the orientation of the camera, and the player collisions are handled by an AABB.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!