0

I'm currently using the Nape physics engine for a "Peggle" style game in ActionScript 3.0.

enter image description here

It is very easy to use, and runs smoothly. However, The only difficulty I'm running into with Nape is replaying the exact same simulation.

Even if I supply it the same timestep value throughout the entire gameplay, it seems to have enough "error" in the calculations that the ball hits different pegs every once in a while (starting the round from scratch), sometimes even resulting more or less lit pegs.

So my question is:

Is there any other physics engines for Flash that can reproduce a given simulation EXACTLY the same each time it is relaunched?

EDIT: The idea of "recording" the data on every-frames and playing it back was tossed around other forums I've asked this question. But unfortunately, the "replay" feature is not so much for the same user to view his/her own ball-drop scenario. It would be used for sharing between players on different machines (ex: client reports a bug with ball drop seeded a value 1234, we punch in 1234 and should be able to see the same issue). So if we pre-record a bunch of scenarios (and by that, I mean ENOUGH to give the player the illusion they are actually running a physics simulation), randomly pick one, and use that random ID as our way to identify a particular scenario, that means we'll need to embed tons of data in the game - that could be otherwise saved if the physics engine was deterministic.


And just to check-off anything I've already tried in Nape:

  • The ball is reset to the same position & rotation at the beginning of the game.
  • The ball's initial velocity is set on user click, therefore this should override any velocity that carried-over from the last round.
  • The pegs don't move (they are static), so no point of resetting those.
  • The part that catches the ball consists of only static boxes and sensors, so no point in resetting those either.
chamberlainpi
  • 4,854
  • 8
  • 32
  • 63
  • 2
    Check out this question: http://stackoverflow.com/questions/24591975/any-way-to-implement-deterministic-physics-in-as3 – Varnius Aug 20 '14 at 14:37
  • Thanks. It's a deceiving question / realization, but still helps getting some closure on the topic. – chamberlainpi Aug 20 '14 at 15:01
  • Replaying a scene with a physic engine should by definition include physics and as a result never be really the same. It would be erroneous to think a similar real world situation would also give the same result, it would not. If the intention is simply to replay a scene then the physic part should be removed and instead all position of all object during the initial play should be recorded and replayed as is. This is not difficult to do and is not either expensive CPU wise during recording or playing. – BotMaster Aug 20 '14 at 16:33
  • But if you need to re-simulate the same scene on a different machine using the same initial values, there should still be a way to get a consistent outcome/replay. And when physics is used "in games", it certainly does not imply "mimicking real-life physics" with all the random forces that may come into play. – chamberlainpi Aug 20 '14 at 17:07
  • Editing the question to explain why there's a need for an exact replay. – chamberlainpi Aug 20 '14 at 17:07
  • You have to save data there's no other choice. A game like counter strike (3d physics) does record scenes by recording data (positions and such) and replaying it not by saving and applying forces to dynamic objects. Since this recording is dynamic I don't see how and why that data would have to be embedded in the app, that doesn't make sense. – BotMaster Aug 20 '14 at 19:07

1 Answers1

-1

The Citrus Engine provide a similar functionality with the TimeShifter you can check it running the demo Braid (pressing [SHIFT] to back in time), the TimeShifter API

  • Voted down. There's clearly a lack of knowledge from the poster. Citrus is only a MVC implementation, whatever internal engine it provides is simply an embedded custom engine in no way made by the Citrus team. As a matter of fact Citrus embed Nape and maybe even Box2D. – BotMaster Aug 20 '14 at 18:54
  • You are right Citrus enbeds Box2D and Nape but TimeShifter is implemented by the Citrus team you can read it here: [V3.1.0 new input system](http://citrusengine.com/v3-1-0-new-input-system-nape-2-multiplayer-friendly-meet-braid/) and you can view the code here [TimeShifter.as](https://github.com/alamboley/Citrus-Engine/blob/master/src/citrus/input/controllers/TimeShifter.as), my answer is pointing to the Citrus Engine because you can't get TimeShifter with nape or box2d alone. – Jesus Boadas Aug 20 '14 at 20:52