I'm trying to add the ability to make bodies static/dynamic without having to remove them and add them again. This code almost works:
But when a moving body collides with the static body, its vertical velocity doesn't get affected, so it will start jumping around and then fall through and off the screen. What's wrong?
Code:
public void setFixed(boolean v)
{
if(v && m_mass != 0)
{
m_pmass = m_mass;
MassData md = new MassData();
md.mass = 0;
md.I = m_I;
md.center = ((PolygonShape)m_shapeList).getCentroid();
setMass(md);
m_type = e_staticType;
}
else
{
MassData md = new MassData();
md.mass = m_pmass;
md.I = m_I;
md.center = ((PolygonShape)m_shapeList).getCentroid();
setMass(md);
}
}
{
if(v && m_mass != 0)
{
m_pmass = m_mass;
MassData md = new MassData();
md.mass = 0;
md.I = m_I;
md.center = ((PolygonShape)m_shapeList).getCentroid();
setMass(md);
m_type = e_staticType;
}
else
{
MassData md = new MassData();
md.mass = m_pmass;
md.I = m_I;
md.center = ((PolygonShape)m_shapeList).getCentroid();
setMass(md);
}
}
But when a moving body collides with the static body, its vertical velocity doesn't get affected, so it will start jumping around and then fall through and off the screen. What's wrong?