[gameprogrammer] Re: 2D Collision

Lag spikes can and will happen for a variety of reasons on modern multitasking operating systems as we don't have complete control of the cpu and os. Say the os decided to switch away from your game to do something like check the network stack or something. You cannot be sure that your game is the only process running on the computer, and besides which driver software sometimes takes a variable amount of time to do the same operation, like doing a bit transfer. I also find the move object time since last update X speed of objects makes debugging a nightmare. I prefer to move each object a certain amount per frame and have a pause that ensures that the loop has a minimum length, say 30 milliseconds.

Dominic McDonnell

Alan Wolfe wrote:

totally good discussion goin on here, im curious too (:

the lag spikes i'm talking about are CPU or GPU related.  My game
designer is way into skill jumps so that was a problem (i hate em
myself too hehe) so just the general small variations between frame
times would make the tiniest bit of difference and made skill jumps
impossible.

I think seperating the logic and drawing into 2 seperate threads could
work, i'd just want to make sure and mutex them so objects wouldn't be
moved while being drawn.

I wonder how a timer would hold up to get the best of both worlds?

On 3/5/07, Scott Harper <lareon@xxxxxxxxxxx> wrote:

Just throwing more ideas out, what if the logic and drawing were
separated?  That is, the drawing remains on the main graphical thread
(with the visual context) whereas the logic processing is offloaded
onto another thread which continually runs?  How would this affect/be
affected by your lag spikes?

Also, are these lag spikes you speak of originating from net-based-
play?  Or are you referring to something else entirely?

As for skill jumps based on a time-passed-since-last-frame system, I
have been able to assume (though this is just on my machine) that the
time fragments will be small enough that as long as I over-compensate
the height at which a player can jump it makes it run okay.  Besides,
nobody likes (read: "I don't like") skill jumps where if you don't
jump on exactly the right pixel you don't make it, forcing you to
have to make a dozen attempts or so. ^_^

Does anyone have any comment, however, on how to make sure one gets
their proper jump level on a system where the logic isn't necessarily
at a fixed rate?  Or do you think that perhaps a fixed rate is indeed
the right way to go?  Is there someone with insight as to how, say,
professional engines handle this?  I would be interested to see how
Quake or Unreal Tournament handle the wide variety of framerates at
which they're run, and also how they handle collision detection!

-- Scott

On Mar 5, 2007, at 9:25 AM, Alan Wolfe wrote:

> it sounds like you have the collision thing well in hand (:
>
> in my side scroller i too had it until recently use the time between
> frames as a multiplier in all the physics and logic equations but i
> hit a problem when it came to lag spikes.
>
> For instance if the player is falling into a deep pit and theres an
> enemy that moves lateraly (imagine the origional metroid hehe) and the
> enemy and the player are on a collision course for the next frame.  If
> there is a lag spike or it's a slow computer, imagine that the player
> is processed first and then the enemy.  Instead of colliding with
> eachother, the player will get processed and be put farther down
> screen and then the enemy will be put where he is supposed to be, but
> the collision wont ever happen because they both moved too far for a
> single frame.
>
> Oh also with using the time between frames as a multiplier, i got
> "random" results with jumps and falls.  Basically it was nearly
> impossible to reproduce a specific jump or walking off a platform and
> landing on a platform below.  It was close every time but it wasn't
> the same every time so skill jumps were not really a possibility to
> put into the game.
>
> What i did to get around this (and so far it works pretty good) is to
> have a "time accumulation bucket" and basically have a while loop...
>
> Bucket += Time_Since_Last_Frame
>
> while (Bucket > some_amount)
> {
>  GameLogic();
>  Bucket-=some_amount;
> }
>
> so that way it processes everything in bite sized increments.
>
> Right now i have the some_amount at 20 miliseconds but i knwo this
> isnt a perfect solution because if the GameLogic() takes more than 20
> miliseconds, there is trouble (:

---------------------
To unsubscribe go to http://gameprogrammer.com/mailinglist.html




---------------------
To unsubscribe go to http://gameprogrammer.com/mailinglist.html





---------------------
To unsubscribe go to http://gameprogrammer.com/mailinglist.html


Other related posts: