Jump to content
  • Advertisement
Sign in to follow this  
TigerSam

Recording

This topic is 3971 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey all, I have a 3d car simulation game which allows the user to drive around a track etc. From the title, what i want to be able to do is to record the users lap somehow. I want to write the lap details to a txt file or equvilent so that at any time i can load this file and the computer will automatically repeat the lap (as many games do). My problem is thinking of a way to implement this. I would have thought writing the users input every frame to a txt file would be expensive, and secondly if the recorded lap is being played on a different machine then the timings will be out. Does anybody have any idea on how i would go about a feature such as this. It doesnt have to be exactly accurate so could maybe record the input every so many frames and interpolate the cars position :?. Im a bit stumped. Any ideas and or pseudo code would be great. Cheers Sam.

Share this post


Link to post
Share on other sites
Advertisement
Basically you've got two main choices: a proper recording system where you log the position/orientation of all objects at fixed intervals and play them back, or a deterministic simulation where you just have to store and play back the user's input to reproduce the same result.

The first means you've got a decent chunk of code to write to store and restore all the object's position, probably with a separate playback mode where normal game logic doesn't apply. Plus your replays will be much bigger on disk. The second approach is easy if you've already got a deterministic simulation, but if you've not then converting a non-deterministic game to be deterministic is pretty tricky. It also means it's not really possible to fast forward/rewind replays.

Gamasutra have a nice article on this subject.

Share this post


Link to post
Share on other sites
You could try recording velocity and position at fixed intervals. Then when you play back, just interpolate between the recorded positions and velocities. It is bascially key frame animation.

Share this post


Link to post
Share on other sites
Quote:
Original post by CodeMunkie
You could try recording velocity and position at fixed intervals. Then when you play back, just interpolate between the recorded positions and velocities. It is bascially key frame animation.

It's worth doing a few calculations before making your mind up. Once you've decided upon a sample-rate, maximum number of objects, which parameters to store and all that jazz, you can work out an upper-bound for the data throughput. Multiply this by the longest expected (or allowed) replay length and you have the maximum size for a replay record.

In my experience (with a similar situation), the everything-but-the-kitchen-sink approach, even at 30 frames/s for several actors, is far less hungry than you might guess. If you can afford the volume of data then I'd recommend this approach, as maintaining determinism is trickier than it sounds, and one little gotcha late-on can cost you a lot of work.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!