Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm working on a space combat sim that takes place over relatively vast areas (a cube of space ~20 light minutes to a side) and uses (mostly) realistic physics. One of the key elements I want to model is the propagation speed of information across the battle space -- that is, if Player A engages his main drive on one side of the battle space, there's a 20 minute delay before Player B sees it and can react to it

Even for relatively small battle spaces this is an important factor given the speeds involved. A 500m long ship doing 30kps is going to displace itself by its full length in 1/60th of a second, so even targeting an opponent just few tenths of a light second away are going to be affected by light lag.

I've not seen this done before, and I'm wondering if there are some best practices for modeling this. Right now I'm timestamping each event and marking it with a location, putting it into a queue, and then each tick checking to see if any of the objects in the game world are newly at the edge of the light cone and adding the event to their sensor queue. I will (but haven't yet) optimize it by removing any events that have already been sensed by all the objects that can possibly sense it, but still, I think this is going to get cumbersome pretty darn fast, and eat up a lot of cycles if there are hundreds of sensing objects in play (which is pretty routine).

Are there data models which would be better suited for this that I should check out?

share|improve this question
Dunno the answer, but I'll say what a neat question! – Tim Holt Jan 21 '13 at 4:39
Whoa! Games are mostly about visualization. I need to know how do you plan to visualize opponents when pixels are far too big? Simple HUD indicators? A text mode adventure game? Please enlighten me! – Jonas Byström Jan 21 '13 at 14:31
You say your model is physically accurate. Is that Newtonian or relativistic? That might make a big difference on such scales. – MSalters Jan 21 '13 at 14:41
Not that it answers the question, but maybe looking at A Slower Speed of Light will give you some ideas. – Michael Pankov Jan 21 '13 at 15:08
@JonasByström - the long-distance view is pretty complex, and I'm trying to clean it up. Basically, I'm hoping it to be a probabilistic view of where the target will be in the future, based on light lag and your ship computer's estimates of the target's max delta-v. Right now it's rather less awesome than that, though :) – John Biesnecker Jan 21 '13 at 21:20
up vote 9 down vote accepted

Just brainstorming here...

Interestingly enough, network lag is your friend in this case. As in you WANT a delay to occur for some data packets, at least if it's about drawing. But instead of a base lag each player would normally have for all data packets impacted by just their network speed, you need to apply specific lag for each event to each player based on the light-speed delay.

Typically the server would send out updates to all clients at the same time, but what you need is for the server to calculate the "light lag" for each event (based on distance of viewer), and then not send out an update until that time.

So for every event, calculate time delay between event and each player, then queue up that event to not be sent for drawing to that player until the delay time has passed.

This doesn't address the effect of the player changing position or speed after the event occurs, but you could potentially adjust events that had been queued based on player changes. A player begins to move closer, move event closer in time. Player moves away, move away in time.

Doppler shift would be an interesting thing to throw into the mix, based on the movement delta between viewer and event.

share|improve this answer
I already sort of model the changing position and speeds. Despite the scale, objects in the game don't generally get going an appreciable fraction of the speed of light, so events overtake them relatively easily, but there is a check at each tick if the receiver is in the the sphere that could have seen the event, so if you're moving toward or away at a good clip it can affect this by a few ticks. Doppler would be interesting indeed, though! Something to look into. :-) – John Biesnecker Jan 21 '13 at 6:10
Something to be aware of, if you use this method, no one scanning the packets will be able to get information before they should. Eve Online does something similar with cloaked ships. When any ship moves in an area all clients are notified, but when a cloaked ship moves the clients aren't told anything. Otherwise although the client doesn't show the ship, the packets would. – Ray Britton Jan 21 '13 at 9:03

The question is: how exact do you need your delayed image to be to how it actually played out? If you're looking for 100% accuracy you're going to need to save either the actions or the state of every object on the map at each tick and, as you say, replay them on a delay based on distance. If you don't care that much about pinpoint accuracy, which you rarely need in games, you can save the state at intervals and extrapolate between them when the delay catches up. You can optimize by not saving identical updates.

Alternatively, you can vectorize all movement and save a path for each object along with a start time seen from a universal observer. Then you can just calculate the expected position of an object for each observer based on the universal time counter the local time based on the path nodes it has saved. When a path node's timestamp goes behind the lightcone of all relevant objects you discard it.

Edit: The above assumes you're going to cheat on basic relativity by having an absolute observer (I assume the player). This would rob you of some of the more Interesting aspects of time dilation but modelling those would be a project in itself >_>

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.