Turning dynamic bodies into static

Hi all,

Is there any easy way to turn a dynamic body into a static one and vice versa? Or do I just have to store the bodyDef instance and recreate a new body each time? If not any reason why it can't be done or if it's just not coded in as part of the engine?

Thanks in advance, I'm using Box2DFlashAS3 2.0.0

regards,
Tommy
Hi!

I think Box2D SourceCode and Box2D API Documentation (.chm Helpfile, Which is included with Official C++ Version) are best resources for figuring out ,on your on, How Engine works.

So I just looked at 'b2Body.as' for you and there it is:
Code:
public var m_type:uint;

// m_type
//enum
//{
   static public var e_staticType:uint    = 1;
   static public var e_dynamicType:uint   = 2;
   static public var e_maxTypes:uint    = 3;
//};


But I doubt that you can just simply set this value and expect results. I think you will need to SetMassFromShapes() again Or may be some other settings as well! Lets ask some Pro Together eh?

Ali Shah
http://www.shah-soft.com
Thanks I have in fact already tried setting m_type directly but unsurprisingly it didn't work 🙂
I think this might help you out. I had the same exact question and was able to make it work. Pretty simple, actually (though not as easy as setting a flag on the object 😉 ).
Thanks that works!

Maybe it makes sense to add in these functions into the library? i.e. b2Body.setStatic(Boolean)
I agree.
I believe functionality for switching between Static and Dynamic body types is restored in Box2D v2.0.1.

Original thread: https://box2d.org/forum/viewtopic.php?t=934