Rotate PhysicsBody around scene's axis

I’m working on my version of a labyrinth.

According to this playground example, I can manage the rotation of meshes to decide whether they should rotate around their own axis or the scene’s axis.

However, I’m having issues applying the same behavior with a PhysicsBody. In other words, are there any ways to rotate my PhysicsBody around the Z-axis of the scene instead of its own axis when I press KeyJ or KeyL?

I think your issue is related to physicsBody.disablePreStep, which for performance reasons is normally true. If you want to modify the physicsBody position or rotation outside the control of the physics engine, set disablePreStep = false until the next scene.onAfterPhysicsObservable.

You can read about disablePreStep here.

2 Likes