adjusting animation speed across machines (Jack) 2004-01-29 - By Neto
Back My favourite way to move my time-based objects is to have a global called "frameTime" or something.
Everyframe, before all other code is called, I fill it up with:
global frameTime, timeSinceLastFrame
frameTime = timeSinceLastFrame/1000.0 frameTime = max(frameTime, 0.1) timeSinceLastFrame = the milliseconds
The second line is a safety check. It caps the 'frameTime' to 0.1 seconds, so the game will limit the speedups to 10fps. If the game runs at 1 frame per second, the game will work as if it were running at 10fps, to avoid major jerkiness (but this is not recommended for multiplayer games).
Then, in the application itself, ALL speeds are in units-per-second. When moving something I just do:
model.translate(direction*speed*frameTime)
-- -- Original Message -- -- From: "Paul Fortier" <pf@(protected)> Cc: <dir3d-l@(protected)> Sent: Thursday, January 29, 2004 1:12 PM Subject: Re: [Dir3d-l] adjusting animation speed across machines (Jack)
> Thanks Jack. I was hoping not to have to do checking (if I could test > *something else* about the machine before the walk sequence happened and > adjust the playrate accordingly). But that might be what I must do. > > Do you mean I should use a timeout to move the character? What do you > mean by 'last update'? > Thanks, > Paul > > Jack Kristoffersen wrote: > > > Check time that has passed since last update and move accordingly. That > >way your character will move the same distance independent of frame rate. > >The playrate is already time based so you don't have to worry about that. > > > > > > > > Jack. > > > > > > > > > > > > > > > __ ____ ____ ____ ____ ____ ____ ____ ____ ____ > Dir3d-l mailing list > Dir3d-l@(protected) > http://nuttybar.drama.uga.edu/mailman/listinfo/dir3d-l >
__ ____ ____ ____ ____ ____ ____ ____ ____ ____ Dir3d-l mailing list Dir3d-l@(protected) http://nuttybar.drama.uga.edu/mailman/listinfo/dir3d-l
|
|