I have a game where user controls a character (with his finger) and i would like to add functionality so the user can record his moves while playing and then play it back. The problem is that the game includes physics and i guess it would be very hard to replicate the exact same moves. How can i implement such a system that will perfectly replay all the users actions? Do i have to record every touch and then play back all the touches? Does any one have any experience with this? I am using Box2D for physics.
Asked
Active
Viewed 2,522 times
1
-
no experience doing this, but saving the touch events seems likely. – Colin D Jun 20 '12 at 17:19
-
"We record replays by storing keystrokes and frame numbers" - http://www.box2d.org/forum/viewtopic.php?f=3&t=1982&view=next Seems as if it's the only way to do it. Write these to a PLIST or something and you'll have your replays. Also, if your physics isn't already deterministic (ie. random) then just take down the random values too) – prince Jun 20 '12 at 17:20
-
@JamesPrince thanks you have pointed me in the right direction. There is a simple solution to this problem at the last page of comments. The idea is to store positions/rotations for every frame and then just replay them back without the physics part. If you would post an answer i will accept it. – blejzz Jun 20 '12 at 17:26
1 Answers
2
"We record replays by storing keystrokes and frame numbers" - box2d.org/forum/viewtopic.php?f=3&t=1982&view=next Seems as if it's the only way to do it. Write these to a PLIST or something and you'll have your replays. Also, if your physics isn't already deterministic (ie. random) then just take down the random values too)
From the comments:
"Just record all the position and rotation state for all the objects every frame (or every other possibly), then, when you want to play things back simply skip the physics engine entirely and just reposition your objects every frame from your recorded position/rotation states.
All you'll need to do is make sure your frames for the play-back are the same duration as they were when the physics was running."