Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Physics - strange behaviour

in Bugs Posts: 4

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?

Tagged:

Comments

  • dave1707dave1707 Mod
    Posts: 7,427

    @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.

  • dave1707dave1707 Mod
    Posts: 7,427

    @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.

  • Posts: 4

    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 :) 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..

  • Posts: 4

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

  • dave1707dave1707 Mod
    Posts: 7,427

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

  • edited October 2018 Posts: 4

    @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.

  • dave1707dave1707 Mod
    Posts: 7,427

    @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.

Sign In or Register to comment.