Page 1 of 1

Immovable Entities

Posted: Mon May 16, 2011 2:49 pm
by lareusoular
How can I make an Immovable Entity on the new version of bEPU?
I changed the assembly because I tought it was useful to see the SourceCode :P

I'm serializing some objects, like this:
this.Immovable = Data.GetData<bool>("BepuEntity.Immovable");

private bool immovable;
public virtual bool Immovable
{
get { return !Entity.IsDynamic; }
set
{
immovable = value;
if (value)
{
Entity.BecomeKinematic();
Entity.LinearVelocity = Vector3.Zero;
Entity.AngularVelocity = Vector3.Zero;
}
else
{
if (Mass == 0)
{
Mass = 1;
}
Entity.BecomeDynamic(Mass);
}
}
}

Then, after calling Entity.BecomeKinematic(), after the Space.Update() the Entity becomes Dynamic AGAIN. So I tried on Update:
if (immovable)
{
Entity.BecomeKinematic();
Entity.Mass = float.PositiveInfinity; // Tried this because I REALLY didn't know what to do =( (and still don't)
Entity.InertiaTensor = Matrix3X3.CreateFromMatrix(InfiniteMatrix());
Entity.LinearVelocity = Vector3.Zero;
Entity.AngularVelocity = Vector3.Zero;
}

now it was better, But I can push the walls, the doors, the everything on my game ¬¬... What's wrong?

Re: Immovable Entities

Posted: Mon May 16, 2011 3:10 pm
by lareusoular
Delete this :oops:
I was making something like:
if (Mass > 1000)
Mass = 1000... That was turning them dynamic...