Speeding up a game question

Started by
10 comments, last by Strewya 10 years, 2 months ago

His original description sounds simple. Doubling delta time will effectively just double the speed, will double the distance traveled in one frame and will fail horribly if things are determined on a "snapshot" base. If enemy x starts the movement outside a towers range and ends the movement behind its range, the tower won't fire at it in the first place. Bullet speed never comes into play.

Keeping the simple approach can work, as long as all speeds and sizes/ranges are carefully designed and in combination with fixed time steps. It will still be inconsistent. Assuming the time step allows an enemy to move half a tower radius, it might start shooting anywhere from the enemy just barely having entered and the enemy already being halfway through. Not even fixing time steps can help with this (though aligning everything in a grid of carefully selected size could).

Personally I'd prefer to go with the extra math: you don't just check "is the enemy in range now", but "did it move through my range this update, at which point did it enter, when did the tower start shooting, where exactly did bullets hit the enemy during its movement, etc.". I like to believe that treating movement as stuff actually moving, rather than just teleporting around is somewhat important to have "proper" physics.

Of course, sometimes "simple and kind of good enough" is all you got time for...

f@dzhttp://festini.device-zero.de
Advertisement

I'd say there's something fundamentally wrong and game breaking if units are fast enough to pass right next to the tower and avoid it's firing range in one frame. Either the time step is way too large, or the metrics for unit speeds/tower ranges are designed wrong.

Having a 16ms timestep, units should move a fraction of a meter, and not 40 meters (assuming a tower has a range of 20 meters). Maybe the design should be changed a bit so units don't move fast enough to skip towers?

devstropo.blogspot.com - Random stuff about my gamedev hobby

This topic is closed to new replies.

Advertisement