Ability to disable collision between specific components

The issue - imagine you have a car with a chassis and four wheels. You don’t want wheels to collide with chassis of the same instance of the car where you have these wheels but still have collision with chassis of other cars.

Perhaps I’m missing something obvious but so far I don’t see the way how this can be solved besides modding the engine’s source and exposing Contact Callback of PhysiX, then intersepting contact between pair of specific objects and setting contact to ignore.

Yeah I think you’re right that UE4 doesn’t provide this flexibility on the level of individual pairs of bodies. They do something similar for kinematic actors (search ‘MoveIgnoreComponents’ in the engine), but not for simulating bodies it seems.

I’m guessing you’re doing custom physics so not using constraint components/PhysX joints between wheel and chassis? Since in those cases there is a flag available to disable collision between the two bodies constrained by the joint.

Just occurs to me that you could still try a horrible hack - set up a constraint between them anyway, check it’s ‘DisableCollision’ flag, and then configure it as a null constraint that doesn’t constrain any degrees of freedom. Not tried myself, don’t know if it would work and it would probably have a minor performance impact if it did, but worth giving a go.

That could work. But this means that you have to setup such constraint potentially between multiple pairs of simulating components as “DisableCollision” effects only two connected.
In situations when simulating components is at least one component away from root. Like Chassis -> Suspension -> Wheel. One would need an extra set of constraints between each wheel and a chassis which role is to just disable collision. Constraints have rather steep performance hit (I don’t know if non limiting one without drives just idling or iterating over calculations) and they won’t help in case of non-simulating bodies.

In regards to non-simulating bodies. I’ve checked my code again and this issue is limited to BPs actually. From c++, sweeps have input array for bodies to ignore. So I could expose ComponentSweepMulti() to BPs and it would be solved.

+1, would also love to have this functionality.

I have characters throwing physics objects at each other, but don’t want the character throwing the object (and only that character) to collide with it as it is being thrown.
So it seems like the only real supported way of doing this, short of changing it to use overlap instead or teleporting it in front of the character, is to make separate collision channels for ignoring every character in the game, which really isn’t scalable at all.

The old physx (2.8.x) has this feature in which you can disable collision or notification within group. Eg disable collision between custom trigger with all other objects and this can be done as long as you have the object physics handle (in 2.8.x it was NxActor, it is probably the same thing too in 3.x).

You will also need to link to physx library directly.

All in all, it is most probably doable (havent tried it myself) without modding the engine source.

Thanks for the tip.

I had a bit of a dig around, but unfortunately can’t think of a way to set up custom collision filtering for the physx scene (either by filter shader or filter callback) as the PxSceneDesc is only used in FPhysScene::InitPhysScene and doesn’t seem to be accessible from anywhere else.
Not sure if that’s what you’re thinking of, but looks like you would probably have to mod the engine and change the filter shader.

Here is what I had done back in the old 2.8.4 Physcs:

mScene->setGroupCollisionFlag(PhysicsUtil::GROUP_AIVEHICLE, PhysicsUtil::GROUP_BARRIER, false);

The code above disable collision between all Phys actor in group GROUP_AIVEHICLE and GROUP_BARRIER. The function setGroupCollisionFlag is direct Physx function from class NxScene.
And you assign actor to group using function like below:-


where actor is NxActor (Physx object handle)

You can certainly disable collision in a group-wise manner in UE4. You just need to set up object types and profiles in the project settings - there is some more info here: Collision Filtering - Unreal Engine

We would like to avoid global pairwise disabling because this could add significant cost to all collisions, as they would all need to do a lookup in this global table. We already have problems with performance for collisions within a PhysicsAsset where you can disable on a pairwise basis.

Group wise disabling, it does not work well for multiplayer.

In physx, if memory serves, it maintain a list of ignored actors that it will check after broadphase. Currently the alternative is the let the collision happen and filter on my side, which is even worse in terms of performance.

Groupwise disabling doesn’t work for a very simple case like vehicle wheels, which shouldn’t collide with chassis of own vehicle and other wheels of the same vehicle but collide with any part of another vehicle. If I use traces or sweeps then I don’t have this problem as you always ignore collision with any component of the same actor. But traces/sweeps don’t do actual collision with other objects.
Contact callback from PhysX could be used for this, right? I don’t know what are the performance cost for it, but PhysX snippet for vehicles uses contact callback for all kind of things.

So here’s an example where I need Ignore Actor. It’s a multiplayer car game, where I spawn attachments onto the car at runtime.


So I would want the collision of attachment to ignore with the vehicle. Currently the physics will blow up when it is spawned. IgnoreActorWhenMoving is not the right way, it should be ignored at physx NxActor level. It needs collision as it can be destroyed.

So what’s the correct way to do this without ignore actor?

if I understand correctly, this issue and many other functionalities can be solved by using PhysX Contact Modification. This PhysX snippet does it and I believe that PhysX vehicle movement component might be using it too:…ContactMod.cpp
The application goes way beyond just ignoring collision between certain components but allow to put rules in place as to how collision will be resolved. Like for example, a vehicle as in Mario Cart, during collision with wall can be forced to just slide along the wall instead of flying over the wall as result of collision.

Skylander’s dev used such rule system for solving collision between vehicles and other objects:

explanation starts at 34:23

I noticed that 4.20 has PhysX Contact Modifications but I couldn’t figure out how they planned us to implement it on the project.

Is there any Epic’s physics dev out there that could explain mainly how are we supposed to get access to PxContactModifyCallback’s onContactModify (which is the actual place where we get all the contact data to modify). I would have expected it to be overridden here :…XPublic.h#L436 but it’s not.

Either part of the implementation is missing or this is designed to work in way I didn’t realize. I know how I could extend this if I modified the engine code (I’ve done PhysX Contact modification support for UE 4.15, 4.18 and 4.19 in past) but surely there has to be a way to use engine feat without making a custom fork?

edit-> Here’s an additional wrapper I made that lets you use these new contact modification changes:…067bda6ebe677a but it obviously still requires a custom engine build + I had to make some minor modifications to be able to expose it all nicely in the editor.

To disable collision between indicated physical body pairs you need to create your own ContactModifyCallbackFactory derived from IContactModifyCallbackFactory and ContactModifyCallback derived from FContactModifyCallback.

Or just use my plugin :slight_smile: