Gamestudio Links
Zorro Links
Newest Posts
Zorro 2.70
by jcl. 09/29/25 09:24
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
1 registered members (TipmyPip), 18,449 guests, and 6 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
Timestep #381979
09/02/11 21:47
09/02/11 21:47
Joined: Mar 2009
Posts: 186
V
Valdsator Offline OP
Member
Valdsator  Offline OP
Member
V

Joined: Mar 2009
Posts: 186
So I've been experimenting a lot recently, just making some prototypes for ideas I have, having some fun. It's all going very well, except for one problem. There's always an issue with something being affected by the framerate, even when time_step is being used. I just made an FPS movement system, and tried out different framerates. You jump higher when the framerate is higher.

Confused about why this keeps happening, I did some research on Google, about timestep and all that stuff, and apparently this has been a problem in games for a while, certain things being affected by the framerate. In the Quake games, if you have a lower framerate, you don't jump as high. I was just wondering... is it possible to get around this? I read about there being a variable timestep and a fixed timestep, but don't really understand what the difference is. I assume it has something to do with how certain games slow down everything if the proper framerate isn't being reached, and other games just making everything move more/less every frame if the framerate isn't correct.

So, my question is: Is there a way to make my jumping less affected by framerate? I don't want players with an fps of 20 to get stuck on a platforming section or something...

Thanks in advance. laugh

Re: Timestep [Re: Valdsator] #381981
09/02/11 22:14
09/02/11 22:14
Joined: Jul 2008
Posts: 1,178
England
M
MrGuest Offline
Serious User
MrGuest  Offline
Serious User
M

Joined: Jul 2008
Posts: 1,178
England
other than setting fps_min and fps_max to the same i'm having the same problem

Re: Timestep [Re: MrGuest] #381990
09/02/11 23:10
09/02/11 23:10
Joined: Dec 2008
Posts: 1,660
North America
Redeemer Offline
Serious User
Redeemer  Offline
Serious User

Joined: Dec 2008
Posts: 1,660
North America
The timestep variable is set by getting the arithmetic difference between the current clock time and the clock time of the last frame. Because the time difference between one cycle and another is minute, the FP unit often times cannot accurately record the difference. If your framerate is especially high, the FP unit may record the time difference as 0 and everything in your world will stop.

This is one of the many reasons why games are typically locked to 60fps. It completely prevents these apocalyptic scenarios from happening. wink

Regarding your problem with movement and stuff, though: there isn't any way to totally defeat the problem. But instead of writing this:
Code:
speed = 16 * timestep;


You could write this:
Code:
speed = 16 * max( 1-timestep, 0 );


This tends to return more uniform results.

Another trick is to provide a smooth gradient for these time dependent variables. That is, make your "totalspeed" variable something that is only indirectly affected by timestep through velocity, inertia, and friction variables.

Last edited by Redeemer; 09/02/11 23:14.

Eats commas for breakfast.

Play Barony: Cursed Edition!
Re: Timestep [Re: Redeemer] #381992
09/02/11 23:29
09/02/11 23:29
Joined: Apr 2007
Posts: 3,751
Canada
WretchedSid Offline
Expert
WretchedSid  Offline
Expert

Joined: Apr 2007
Posts: 3,751
Canada
Originally Posted By: Redeemer
the FP unit often times cannot accurately record the difference. If your framerate is especially high, the FP unit may record the time difference as 0 and everything in your world will stop.

Not true, the clocks inside a x86 PC are accurate enough to get times in the sub millisecond range, otherwise a today OS couldn't work very well. Its also possible to grab the time as double precision floating point from the OS, being valid for about 10k years in the sub millisecond range, subtracting the old time from the current time and converting it to single precision floating point afterwards doesn't really reduce the accuracy by much.


Shitlord by trade and passion. Graphics programmer at Laminar Research.
I write blog posts at feresignum.com
Re: Timestep [Re: Redeemer] #382053
09/03/11 19:45
09/03/11 19:45
Joined: Mar 2009
Posts: 186
V
Valdsator Offline OP
Member
Valdsator  Offline OP
Member
V

Joined: Mar 2009
Posts: 186
Originally Posted By: Redeemer
But instead of writing this:
Code:
speed = 16 * timestep;


You could write this:
Code:
speed = 16 * max( 1-timestep, 0 );


This tends to return more uniform results.

I assume you mean:
Code:
maxv(1 - time_step, 0);


...but that doesn't seem to work. Jumping in 60 FPS is completely different than jumping in 20 FPS. I tried it in the c_move for jumping, and in the command that decreases the variable "z_move" (which is used in the c_move). Perhaps I'm not using it correctly?

Thanks for the help so far. laugh

Re: Timestep [Re: Valdsator] #382060
09/03/11 22:02
09/03/11 22:02
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline
Senior Expert
Superku  Offline
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
The problem is not time_step but the fact that movement per frame is linear, I hope the following sketch explains the problem:

(The result is, of course, the same when you only jump in z-direction.)


"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual

Check out my new game: Pogostuck: Rage With Your Friends
Re: Timestep [Re: Superku] #382290
09/06/11 21:56
09/06/11 21:56
Joined: Mar 2009
Posts: 186
V
Valdsator Offline OP
Member
Valdsator  Offline OP
Member
V

Joined: Mar 2009
Posts: 186
I don't understand. What do you mean by "movement per frame is linear?"

Re: Timestep [Re: Valdsator] #382291
09/06/11 22:11
09/06/11 22:11
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline
Senior Expert
Superku  Offline
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Have a look at the sketch:
Your entity won't move along the curve, instead it will move straight from one black arrow to the next. As a result, the entity probably will not reach the maximal height (= green line) on a low framerate.


"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual

Check out my new game: Pogostuck: Rage With Your Friends
Re: Timestep [Re: Superku] #382524
09/09/11 01:04
09/09/11 01:04
Joined: Mar 2009
Posts: 186
V
Valdsator Offline OP
Member
Valdsator  Offline OP
Member
V

Joined: Mar 2009
Posts: 186
Ah, I see. Is there a way to prevent this? Or at least, reduce the effect?

Re: Timestep [Re: Valdsator] #382525
09/09/11 01:42
09/09/11 01:42
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline
Senior Expert
Superku  Offline
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
I'm working on a platformer/ jump'n'run and I simply "ignore" it. I just make sure that the game works on 20fps+ and that you can reach every platform and make every jump.
You could write a code that only allows downward movement when you've reached a certain height (f.i. starting height + 256 quants), but this would deform the jumping curve and result in different timeframes.


"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual

Check out my new game: Pogostuck: Rage With Your Friends
Page 1 of 2 1 2

Gamestudio download | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1