I understand that I can achieve this effect in versions 1.4.3 and 2.0.1 by setting the mass to 0. How can I do this in version 2.0.0?
Make a Dynamic Body Immovable?
FlashCreateBody was briefly split into CreateStaticBody and CreateDynamicBody
BorisTheBrave wrote:
CreateBody was briefly split into CreateStaticBody and CreateDynamicBody
Right but what I'm hoping is that I don't have to create two separate bodies and switch between them to lock the object to a specific point.
As Box2DFlashAS3 is only at version 2.0.0, how do we go about locking a body to a specific position while maintaining collidability?
Try:
You will also have to zero the angular and linear velocities if the body is moving when you make it static.
Not sure if there's anything else.
Let me know how that goes anyway.
-Matt
Code:
body.m_type = b2Body.e_staticType;
body.m_mass = 0.0;
body.m_invMass = 0.0;
body.m_mass = 0.0;
body.m_invMass = 0.0;
You will also have to zero the angular and linear velocities if the body is moving when you make it static.
Code:
body.m_linearVelocity.SetZero();
body.m_angularVelocity = 0.0;
body.m_angularVelocity = 0.0;
Not sure if there's anything else.
Let me know how that goes anyway.
-Matt
skatehead wrote:
Try:
You will also have to zero the angular and linear velocities if the body is moving when you make it static.
Not sure if there's anything else.
Let me know how that goes anyway.
-Matt
Code:
body.m_type = b2Body.e_staticType;
body.m_mass = 0.0;
body.m_invMass = 0.0;
body.m_mass = 0.0;
body.m_invMass = 0.0;
You will also have to zero the angular and linear velocities if the body is moving when you make it static.
Code:
body.m_linearVelocity.SetZero();
body.m_angularVelocity = 0.0;
body.m_angularVelocity = 0.0;
Not sure if there's anything else.
Let me know how that goes anyway.
-Matt
Woo! That seems to have done it. So far so good. I assume that there's an 'e_dynamicType' static variable in the b2Body class? I'll take a look-see. Thanks!
Original thread: https://box2d.org/forum/viewtopic.php?t=741