SOLVED!
YOU SHOULD NOT USE SetMassFromShapes MID TIMESTEP. DO IT AFTER THE CYCLE
Hi
I know there has been a few topics that cover switching from dynamic to static, but there isn't much about going the other way.
In my game, bodies regulary switch from static to dynamic and back again.
Here is my code
Setting bodyStatic to true seems to work.
Setting bodyStatic to false doesnt always work. The mc alpha is working correctly, but when I view the bodies in debug mode some of them are outlined in green (static) even though they are alpha.
All bodies start dynamic (using body.SetMassFromShapes())
Any help on this would be great!
Cheers 😛
YOU SHOULD NOT USE SetMassFromShapes MID TIMESTEP. DO IT AFTER THE CYCLE
Hi
I know there has been a few topics that cover switching from dynamic to static, but there isn't much about going the other way.
In my game, bodies regulary switch from static to dynamic and back again.
Here is my code
Code:
public function set bodyStatic(val:Boolean):void
{
if(val)
{
body.SetMass(new b2MassData());
mc.alpha = 1;
}
else
{
body.SetMassFromShapes();
body.WakeUp();
mc.alpha = 0.2;
}
_bodyStatic = val;
}
{
if(val)
{
body.SetMass(new b2MassData());
mc.alpha = 1;
}
else
{
body.SetMassFromShapes();
body.WakeUp();
mc.alpha = 0.2;
}
_bodyStatic = val;
}
Setting bodyStatic to true seems to work.
Setting bodyStatic to false doesnt always work. The mc alpha is working correctly, but when I view the bodies in debug mode some of them are outlined in green (static) even though they are alpha.
All bodies start dynamic (using body.SetMassFromShapes())
Any help on this would be great!
Cheers 😛