woensdag 13 juli 2011

Replay fun

Dear readers,

I've been working on another car game and last friday afternoon after doing some boring stuff I felt like doing something fun and that could be done quickly: a replay function. None of our games currently have this, but for the game I'm doing now I think it would really add something.

Before we can replay anything of course we need to record. The first thing that comes to mind is to simply store our key input and on replay the stored key input is used as input for the car. But as we're using a physics engine which I don't trust to be deterministic (the same input results in the same output) it would lead to a different replay which of course is not what we want.

Another approach which is easy and sure to work is to store the transforms of the car each frame in a list and when on replay simply go through the list and setting the car model to the stored transform. This is what I currently do and it works well. But let's analyze it. We're running at 30 frames per second and thus storing 30 transforms per second. For each minute of replay we store 30 * 60 = 1800 transforms. Assuming each transform is stored as a 4x4 matrix of floats, so 16 floats at 4 bytes per float: 64 bytes per matrix. And so for each minute of replay 1800 * 64 = 115200 bytes. Considering today's RAM capacity in computers this is peanuts. But this of course is only for a single car and additional actions have not been recorded (for example car damage, firing of weapons, etc). One way to reduce the size of the replay list would be to store the transform every X frames and interpolate between transforms, although you do lose accuracy with this approach. Another way is to only store transforms when they've changed 'enough' with respect to the previously stored transform. In this way a car that does not move would not cause the replay list to increase in size.

With a replay you can think of simply watching what you (or someone else) did. Currently I implemented it as a replay while you're playing: like a ghost rider (See image below). In this way you get the feeling you are competing which in my opinion adds to the fun and I hope the option will be there when we release the game.

Image from 'BMX Ghost'. A ghost rider is shown displaying the best round you previously played.

-- Stijn

3 opmerkingen:

  1. ROBLOX is powered by an ever growing community of over 300,000 creator players who generate an infinite variety of highly immersive experiences.

    These experiences range from 3D multiplayer games and contests, to interactive adventures where players can take on new avatars discovering what it feels to be a dinosaur, a miner in a quarry or an astronaut out in space.

    BeantwoordenVerwijderen