Physics - strange behaviour

Hi all,

Enjoying Codea, recently started creating physics racing game and faced 2 problems with physics.

These problems reproduce in the Physics Lab built in example as well:

  1. The physics appears not to be deterministic, although it should, since Codea is using Box2D with fixed step. If you check Test 7 in Physics Lab, with every restart the collisions are slightly different.
  2. If you check Test 6 (with the car), occasionally you can notice some wobbling of the car in relation to its wheels, especially if you increase car speed.

I am seeing the same behaviour in my own game. Tried increasing physics.iterations with no effect on either of the issues. Any advice?

@fvoin That was part of a discussion that I started many, many years ago. I had several balls bouncing on the screen and I recorded their positions every so many collisions. After several restarts, I compared the list of positions and some were the same and some were different. Other people also responded that their games didn’t have the same results on every restart. Apparently every restart doesn’t begin with the exact same conditions.

@fvoin Glad to read that you’re enjoying Codea. I’ve been using it for over 6 years and I’m still enjoying it. And there’s still a lot of things that I discover that I don’t know about.

Thanks for your reply Dave! I think Codea is a great tool, especially for quick prototyping! Simplicity is King, and guys at Two Lives Left found a nice recipe for it :slight_smile: However this physics issues are just ruining the game experience so I am thinking about possible workarounds. Writing my own physics add on is the only option I have in mind so far…

@dave1707 Ok just solved #2! If you set interpolate = true to physics.body, wobbling vanishes! :slight_smile: Now to #1

@fvoin What are you doing that you need the exact same results after a restart or on different runs.

@dave1707 I am creating a multiplayer racing game. I record player inputs (touches) that control vehicle on each of the devices, and synchronize them with the server. Each player receives inputs of all the vehicles from the server that are replayed on their devices. Problem here is that simulation on each of the devices is slightly different, so each player gets “his own simulation”, while it should be identical.
One possible solution might be to assign one of the devices as a “server” for the simulation, and continuosly submit snapshots of the physics world (positions, velocities, etc) instead of player touches to all other devices. But this solution is much more vulnerable to network lags, and harder to implement.

@fvoin I think we’re talking about different problems. The one I’m referring to is running a physics program and seeing slightly different results if the program is restarted or run again from scratch. What you’re describing is getting different results by multiple people over a network. If you search for multiplayer games, you’ll see a lot of comments about info being dropped or a lot of lag.