I’m trying to have a vehicle (dynamic object) run through a character (kinematic object). Currently, my vehicle just bounces back from colliding with kinematic objects. I’m not looking to turn off the collision between these object types. I still want to handle the contact event: slow down vehicle a bit based on its velocity before impact, do damage or kill character from collision.
Can somebody please tell me what’s the best approach to achieve this?
Thanks in advance.
A kinematic actor has infinite mass so, if you let a dynamic collide with it, the dynamic is always going to bounce off.
When doing things like this in the past, I’ve
(1) Filtered so that the vehicle doesn’t collide with the kinematic character controller in the PhysX simulation. You can still have the character controller collide with the vehicle as part of the CCT update, which will allow the CCT to not walk through a vehicle, brush along the side of it, stand on it etc. You could apply forces on the vehicle to have some response to these collisions (this should be good-enough as a vehicle will only respond slightly to a human pushing against it but, importantly, the character can’t pass into the vehicle).
(2) Use a trigger that will transition the character ragdoll from kinematic to dynamic and then adjust filtering so it collides with the vehicle if you decide to kill the player (e.g. if the car is going fast-enough to kill a character). You need to make sure this happens at least 1 frame before the human gets hit by the car. You could use raycasts/sweeps to achieve this in your logic, or use triggers.
(3) Character transitions to ragdoll and gets hit by the car.
If you want to gently push the CCT back, but not kill the player, then option (1) should kind of work, depending on the implementation details of your character controller (does it take the speed of impacting objects into account, can it recover from penetration from a moving object etc.).
@kstorey, thanks for all that great info. I do have a question for option (1), if I filtered so that vehicle doesn’t collide with CCT how do I still get notified that collision happened with these two object types? I still need to know that collision happened and apply backward force to vehicle and damage/kill the character.
Sorry if that’s something obvious. This is my first project using PhysX so I’m still learning the ropes.
Found it. It looks like the function I’m looking for is PxSimulationFilterCallback::pairFound().
Thanks for the help.