Inconsistent Physics between Engines (playground)

My demo is below, but first my explanation. I’m building a real time networked game that requires physics. I run the game simulation both in the browser, and in a node backend server using NullEngine. Everything seems to work, except the exact same physics configuration in NullEngine and Engine are completely inconsistent.

With NullEngine physics, the boxes seem to slide into each other, and perform some odd ball settling looking physics. The worst is that the rigid bodies will completely intersect each other for periods of time before rejecting each other slowly. This does not at all happen on the normal Engine.

I’ve reproduced the same issue inside babylon playground using null engine. Since playground limits the size of the demo, grab the pastebin and paste it into the playground.

Steps to Reproduce

  • Grab the left textured box with your cursor, slam it into the right textures box and play around with it. It feels good and right
  • Grab the left untextured box (from the null engine) and slam it into the right untextured box. The physics do really really really weird stuff.

1 Like

I can’t answer your question, but AFAIK there’s no limit in code size for the PG (or it is a big one).

Here’s the PG corresponding to your code:


My entire startup hinges on getting this right, so I’m deep in debugging on why this is broken. I’ll definitely report back, and perhaps even recommend a pull request if I can find out why this is happening. If you, or anyone has any idea to help me along the way I would sorely appreciate it.

It appears that the rotation may be broken and not syncing to the mesh, only the position.

ok yes… rotation is totally broken and not being updated in the null engine for some reason. rotationQuaternion does seem to work. It looks like the quaternion isn’t marked as dirty so it’s never syncing over to rotation. I thought this might be a me problem, but i’m 100% convinced I’ve run into a babylonjs bug now.

Adding @RaananW who is fantastic both with physics and null engine :slight_smile: would you have a smaller repro of the issue ? it might help a lot troubleshooting faster.

I greatly reduced the reproduction case. Babylon.js Playground

Just set SHOW_ISSUE = true or false to demonstrate the issue, and see what 2 lines it switches between.

As a side note, my product im working on is here. Completely networked physics in the backend.

1 Like

The rotation parameter is reset once using a physics engine, and only the rotationQuaternion is updated. This is not an issue but a feature of the framework - once you have a quaternion defined, the rotation will no longer be used.

so in this case:

            boxProxy.rotation = nullBox.rotation
            boxProxy.rotationQuaternion = nullBox.rotationQuaternion

only the second one (the quaternion) will work correctly.

1 Like

That makes sense as an explanation to the problem. Thanks for explaining that.

It looks like from an outside who hadn’t seen this explained that, this is a very very easy issue to run into without understanding what the issue is. I don’t have a recommendation, just that I wish I had found this information a bit more easily.

1 Like,_rotation,_scaling#rotationquaternion

@RaananW, @jason.spafford it seems that this warning still applies within the null engine. The warning also remains if the rotation values are set indirectly rather than using mesh.rotation = … I will strengthen the warning.

1 Like