[Feature Request] Ability to disable collision between two physics FBodyInstances

Hello,

I would love to see a C++/blueprint function in Unreal Engine to disable all collision (blocking and overlaps) between two arbitrary FBodyInstances or PrimitiveComponents, similar to this Unity function:

This would be a very useful addition to the existing collision channel filtering system and make the physics in Unreal Engine extremely customizable. It appears that only skeletal mesh components support this kind of filtering at the moment via FPhysScene::CollisionDisableTableLookup.

I am aware of PrimitiveComponent’s MoveIgnoreActors, however this does not appear to affect blocking collisions, only overlaps.

Thanks,

Hi ,

I like the idea but I believe this could be easily achieved with collision channels. If you make a custom collision channel for your character and set them up to be a channel that gets blocked by normal things, but ignores others of it’s own type, you could accomplish this with relative ease.

These two pages should be of some help if you wish to go down this path:

Hope this helps!

Hi ,

Thanks for the quick reply! I’m not talking about characters though - I’m talking about arbitrarily disabling/enabling collision between any two FBodyInstance pairs anywhere in the physics scene at any time. This would be a very powerful bit of functionality, and is something the UE4 collision filtering system can’t approximate right now, especially with the 32 collision channel limit. I believe this is the reason Unity added their Physics.IgnoreCollision function.

Please understand that adding this functionality wouldn’t replace the collision filtering system as it stands, it would just be an advanced-use function to give extra fine grained control. I’m sure you can appreciate that UE4 devs are starting to use the engine for things other than FPSes and there are going to be unforeseen situations that can’t be addressed with collision filtering alone, particularly with MMOs (lots of actors of the same type) and complex actors made up of multiple primitive components that require unusual physics behaviour/interactions.

Let me throw out a couple of examples that will hopefully change your mind.

Imagine a physics-based train simulator game. A train actor is made up of a bunch of box carriages packed tightly together in a row (static mesh components simulating physics), and let’s assume I’m not using the skeletal mesh component or physics joints for this, I’d like to do all the train movement myself in blueprint.

Now, lets say when a train turns a tight corner that the carriages inter-penetrate a little bit at the corners. For art reasons I can’t change the geometry or carriage distances to prevent this. I can easily use the collision filtering system (as you suggested) to prevent carriages from blocking each other but still allow them block the world and other physics props in the scene.
But now imagine I’ve placed two trains in the world. Now none of the carriages will collide with each other, even if TrainA and TrainB overlap! Okay, so let’s make two collision channels, one for TrainA carriages, one for TrainB carriages, and they’ll block each other, but not themselves. That works, but now I want to add 50 more trains to the scene. See the problem?

This is the reason UE4’s SkeletalMeshComponent and PhysicsConstraints have added the ability to disable specific collision pairs internally. It would be great to have it as a more general engine feature that we can use and abuse from C++ or blueprint.

Another example would be a cannonball game for 32+ players. Let’s say there’s only two types of actors existing on a big flat plane: cannons, and cannonballs. Cannonballs are fired out of the cannons at other players’ cannons. Unlike the ShooterGame example, we don’t want to use overlaps for the cannonball projectile collision detection, we want them to use blocking collisions instead so when a cannonball hits someone else’s cannon, it will bounce off it using physics (and deal damage on the hit event). When a cannonball is fired, we want it to spawn well inside the cannon geo/collision and shoot outwards so it looks good visually. So we need each cannonball to ignore collision with its owner cannon only, but collide with all other cannons. We could simply disable cannonball collision entirely for the first X seconds of its life, but that’s a bit hacky - what if there’s an enemy cannon right in front of it? Maybe we could set it to use overlapping collision until it’s no longer overlapping with its owner cannon any more, then change it to use blocking collision after that, but that’s a lot of work compared to just being able to turn off specific collision with its owner cannon.

Hopefully these examples have demonstrated the usefulness of a C++/blueprint function to arbitrarily disable collision between two FBodyInstances in the scene. UE4 already sort-of supports it internally via skeletal mesh components and physics constraints, I’d just love for it to be available elsewhere to make the lives of gameplay programmers a bit easier.

Thanks!

Hi , please see my comment below - there was a character limit in the reply field, apologies! :slight_smile:

Hi ,

I’ve looked it over and it seems like this would be a useful feature when presented with the limit that collision channels have when it comes to numbers. I’ve played a feature request into our system for the function. For your reference the number is UE-16728. While I can’t guarantee that the request will be fulfilled, I will be sure to update you here with any updates to its status.

Have a nice day,

Thanks very much , really appreciate it.

Is there any way to check on this? This issue predates the move to the new tracker and UE-16728 is either missing or private. We’re coming up on 4 years and as far as I can tell this is still missing functionality.

Hello Teiwaz,

This was entered as a feature request and those are not visible in the public issues tracker. I’ve checked it personally however and it’s still currently marked as backlogged. Unfortunately I don’t believe this will be added any time in the near future, with how long it’s been in this same status.

Well, thanks for looking into it.

Is it possible to… like… poke it with a stick, or something? I waded through a dozen or so forum posts, reddit threads, and other answerhub questions, all about this issue before I got here. It’s pretty fundamental functionality which is supported by PhysX, but just not exposed by UE4. (Or was partially exposed in 4.20 but the work was never finished.)

From what I’ve gathered, it’s fairly easy to do if you’re willing to edit engine code, but a huge pain in the butt if you’re not. I’m going to keep digging, but PhysX gives me headaches (not naming variables doesn’t make code run faster, Nvidia!) and UE4’s interface with it is… labyrinthine.

Unfortunately I have no real say in if it is implemented or not. Additionally, with the recent announcement of Chaos at GDC, it’s possible that any changes related to PhysX may be completely on the back burner but I’m not privy to the Physics team’s current goals.

Ah, thanks for bringing that to my attention. If PhysX is being replaced entirely in UE4 in the reasonably near future (presentation on Chaos says preview in 4.23?) then it’s really not worth me putting more time into this right now. I’ll just hold off until the new physics stuff shows up.

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: