Page 1 of 1

Updating entities WorlsMatrix and collision

Posted: Tue Oct 02, 2012 8:12 pm
by Darsa
Hi,
I got question about simple issue which I can't slove by myself.
Im building simple game like racing, I calculate terrain-cars collsion without bepu physic, but on the scene there are other entities; next I move entities-cars by setting their Position; my question is: what I need to do entities-cars collide with themself, becaouse now they goes through each outers like ghost. Is it possibe is I change position of entities-cars by updating its WorlsMatrix?
Thank you,
Darsa

Re: Updating entities WorlsMatrix and collision

Posted: Tue Oct 02, 2012 9:18 pm
by Norbo
Setting position and orientation (or, equivalently, the WorldMatrix) teleports the entity into a new state. Teleportation does not care about entering a penetrating state and will happily scoot through other objects.

In order for collision response to do its job, entities must be controlled with velocities. So, instead of controlling the entity's position and orientation by setting them directly, compute a velocity which accomplishes the same goal. The EntityMover and EntityRotator are convenience classes which will calculate the goal velocity for you. Check out the path following demo in the BEPUphysicsDemos for an example.

If the controlled entity is kinematic, note that it has effectively infinite mass and dynamic entities will be shoved out of the way. Also, kinematic entities do not respond to collisions; they have effectively infinite mass, so no regular simulation force can change their path.

Dynamic entities will respond to collisions, but watch out when blindly setting position and orientation goals: if the goal can't be reached due to obstacles, the constraint will try really hard and bad things (i.e. explosive behavior) might happen. The simulation should be able to provide feedback of some kind to the external controller so that it doesn't keep trying to enter a progressively more invalid state. The ideal case is to just fully integrate the simulations so that there's no ugly seam to work around.