Jump to content
  • Advertisement
Sign in to follow this  
ajm113

My objects that move based on Time, lag. (C++ Project)

This topic is 3621 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

I am trying to fix the performance in my game where every object moves the same speed on different CPU's or Platforms. The issue is that my time performance handler keeps lagging or speeding up my objects when the player model moves for a example and even the player model when it moves lags a bit on some machines. Some Values Of My Movement Speed Variable For How Fast The Object Is Supposed To Move Based On Time. -0.049999997 -0.25999999 -0.44000000 -0.38000000 -0.44000000 -0.37000000 Then times that with 9.0f for being the Units Per Second for the player's Speed or lower for any other object. Now am I supposed to do something between the variable that holds time performance value for the each object that moves to prevent infliction with the other object's speed? I would appreciate help, this is the only thing setting me back releasing the update for my game. Thanks, Andrew. [Edited by - ajm113 on January 8, 2009 12:27:47 AM]

Share this post


Link to post
Share on other sites
Advertisement
It would help if we knew how/how often you calculate your time based movement. I calculate the time to render each frame by calling GetSystemTime() (if you're on windows) before and after the render() function call. Then update my time step based on the time it took to render the last frame. All my movements are based on this one time step value. Hope that helps.

Share this post


Link to post
Share on other sites
There are a couple possible hangs ups that come to mind:

1. How often are you calculating the timestep? You generally want to update it more than once a second to keep the movement fluid. However, if you are updating it too often, then you might run into problems where a complete tick hasnt passed since the last check, which will cause divide by 0 problems.

2. When calculating the timestep, are any of your intermediary results being stored as integers? Besides the frame and tick counts, you will probably want to work exclusively with floating point numbers to prevent rounding/truncating errors.

3. Are you calling a sleep function to normalize the framerate? (i.e. if the framerate goes past 60, do you try to slow it down?) I find using this approach leads to pretty jittery framerates unless your game hovers around the desired fps naturally. If youre using some kind of sleep normalization, I would recommend just letting your game run as fast as possible while recalculating the timestep often.

This advice is coming from an amateur, so you might want to take it with a grain of salt. However, these are all problems Ive run across before and the solutions I mentioned worked for me.

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!