entity lifetime
Im implementing a lifetime in each of my game entities so they will die once they reach their lifetime. My question is how precise theis really needs to be? My game loop updates 30 times per second, so how should i track lifetime? Milliseconds? How could i be precise in millsecs if i only update 30/sec?
It needs to be exactly as precise as you want it to be - no more, no less.
Is there any reason for tracking exactly when within one frame an entity dies? If not, and your frame rate is constant, why not just measure lifetime in frames?
If your frame rate is (or becomes) variable, just measure it in milliseconds. You don't need to check for a precise match to the age each time. Just increase the entity's age each frame by the correct amount and do "if (current_age >= lifetime) kill_me();" to check it.
Is there any reason for tracking exactly when within one frame an entity dies? If not, and your frame rate is constant, why not just measure lifetime in frames?
If your frame rate is (or becomes) variable, just measure it in milliseconds. You don't need to check for a precise match to the age each time. Just increase the entity's age each frame by the correct amount and do "if (current_age >= lifetime) kill_me();" to check it.
Don't you hate it when you're playing a game, and an entity dies after 1023 milliseconds instead of 1000 milliseconds?
lol you make a good point, i guess as long as my fixed timestep update checks for lifetime before doing anything else it wont effect the game, worst case i guess is you see the object rendered 33.33333 milliseconds longer than it should be since i have a variable framerate.
Quote:
I'm implementing a lifetime in each of my game entities so they will die once they reach their lifetime. My question is how precise theis really needs to be? My game loop updates 30 times per second, so how should i track lifetime? Milliseconds? How could i be precise in millsecs if i only update 30/sec?
Exactly as you have said, you cannot be precise in ms, the closest precision you could hope for as you described is 30ms...
Quote:
If your frame rate is (or becomes) variable, just measure it in milliseconds. You don't need to check for a precise match to the age each time. Just increase the entity's age each frame by the correct amount and do "if (current_age >= lifetime) kill_me();" to check it.
my vote for best method... ever... period.
Quote:
Sneftel: Don't you hate it when you're playing a game, and an entity dies after 1023 milliseconds instead of 1000 milliseconds?
schragnasher: lol you make a good point, i guess as long as my fixed timestep update checks for lifetime before doing anything else it wont effect the game, worst case i guess is you see the object rendered 33.33333 milliseconds longer than it should be since i have a variable framerate.
You will *see* that object for 33ms longer....? HAHA!
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement