• Hello [name]! Thanks for joining the GMC. Before making any posts in the Tech Support forum, can we suggest you read the forum rules? These are simple guidelines that we ask you to follow so that you can get the best help possible for your issue.

Windows Box2D fixtures not binding correctly


I've just filed a bug report on this, but I thought I'd post here so anyone encountering this issue can find some information on it, especially since the Box2D tutorials have been re-published, and more people might be trying their hand at it.

I've noticed that sometimes, when using the physics system in GMS2, that fixtures defined in the object editor do not work when the game is run. The instances do not have a physics representation. Objects with their physics properties and fixtures defined and bound via code do not have this problem.

I've realized that the issue only appears when the physics world is created via code. If the physics world is created by ticking the physics box in the room editor, then all fixtures are correctly created and bound, regardless how they are defined.

Here is a sample project to import to see this issue at work. The project currently has the physics world defined via code, with one static object and three dynamic objects. Two of the dynamic objects have fixtures set in the object editor, the third is set via code. Debug drawing is ON. When the project runs, only the code-defined fixtures are created. If you remove the "oPhysics" instance from the room and tick the physics box in the room editor, then everything works as it should.

The work-around is simple, fortunately. If you define your physics world via code, then everything must be done via code.


Yeah this is a bit annoying if you want to place physics objects in your room. I suspect it has to do with the order the code is run, so if you do physics_world_create later, any physics objects that are created before that don't get bound correctly.