the problem is that some times the entities i use to represent the users intersect themselves and it throws an NAN exception
NaN-splosions are likely caused by unclean/invalid input in this case. If the input is infinity or NaN the engine will consume and get infected by bad values. You can verify this by compiling with the CHECKMATH compilation symbol. This will insert checks into most interaction points in the engine to catch NaNs and infinities before they propagate.
The best way to avoid this is to eliminate the source of the invalid input; this may require cleaning the incoming data.
i have found that this can be resolved by using the EntityMover class my problem is that when i set the target position they dont move am i missing something?
If the input data is truly invalid, then using an EntityMover won't actually help avoid a failure of one kind or another. It may not be the same type of failure, though.
If the EntityMover does nothing, it might not be added to the Space.
[I should mention that using EntityMovers is indeed a good idea in this case. Not for NaN-related reasons, though. Setting the Entity.Position or WorldTransform or Orientation amounts to teleportation. Collisions rely on relative velocity; teleportation is not based on velocity, so collisions would be squishy. EntityMovers act on velocities, so collisions will work better. You can do the same thing the EntityMover does externally if you wanted more control, too.]
A few extra notes:
Code: Select all
fJoints[i].Entity.WorldTransform = Matrix.CreateTranslation(position);
The Entity.WorldTransform is a convenience wrapper over the Position and Orientation properties. If you just want to set an entity's position, it's easier to just set the Position property.
Code: Select all
fJoints[i].Entity.PositionUpdateMode = PositionUpdateMode.Continuous;
Setting this one time at initialization is sufficient. Once set, an entity's position update mode will not change by itself.
Additionally, it may be better to set the fast moving incoming objects to Continuous, and just let the bones have the default mode. The balls won't pass through the body and the total number of CCD checks will be less.