Warning! About setting your physics body types (dynamic, kinematic, static)

Just a note for people setting physics bodies to one of the 3 types (dynamic, kinematic, or static).

Quite some weeks back, I was getting odd crashes and strange behavior using the following “legal” code:

physics.addBody( obj, "kinematic", { density=1.0, friction=0.3, bounce=0.1 } )

This behavior recently began repeating itself in my current game, when I tried to apply a physics body to an object larger than, say, 400 pixels in either direction. I would receive a nasty Box2D crash which would in turn bring the Corona Simulator down.

However (good news, I hope!) the crash does not seem to occur when you set the body type after the initial declaration, using “body.bodyType” as follows:

physics.addBody( obj, { density=1.0, friction=0.3, bounce=0.1 } )  
obj.bodyType = "kinematic"  

In this case, the Simulator runs fine. No crashes… at least in my initial testing. Can anybody else confirm this or state if they have had similar issues? Ansca, any feedback on this? I have no problem declaring my physics bodies in 2 lines, but until this bug is resolved, perhaps you should modify your documentation and warn people about using the “all in 1 line” physics body method. :slight_smile:

Brent
[import]uid: 9747 topic_id: 5138 reply_id: 305138[/import]

I can’t confirm that particular bug, but I can add to it slightly. I have a ragdoll with weld joints holding it together. Changing the body type to kinematic seems to remove the joints, or at least they arne’t being honored in the physics engine. Changing them back to dynamic body types seems to snap the joints back together. [import]uid: 8673 topic_id: 5138 reply_id: 17534[/import]

Thats interesting Ignis, I wonder if that would affect other performance issues as well, I’ll have to play around with that.

Mhorsley, I don’t believe you can use joints with kinematic body types. [import]uid: 10243 topic_id: 5138 reply_id: 19511[/import]