Not enough collision layers - Can I use engine trace channels?

The documentation advertises that there are 32 collision layers to play with, but one quickly finds that only 18 of those layers are user-definable :frowning:

Long story short, I have a multiplayer game where players ride physics vehicles - players and vehicles should collide with everything else, but be allowed to overlap each other while the player is riding. Using the ‘ignore actors while moving’ functionality does not work in this case, presumably because I’m using physics simulation on the vehicle (vehicle still receives hits from player while he is attached).

It would solve a lot of problems for me if each player and their physics vehicle could use their own collision layer. However with a 6v6 game, I’m left with only 4 available layers for everything else (2 for an 8v8, which is simply not doable). Without a layer per-player, there are cases where I have to detect overlaps as if they are hits and try to respond appropriately instead of being able to rely on physics & the normal impact response code path.

Looking at the engine source code, the 14(!) missing layers are taken up by the engine. The first 8 are taken up by WorldStatic, PhysicsBody, etc. This is annoying, but expected/manageable . The next layer is ECC_EngineTraceChannel1, which is commented as reserved for gizmo collision.

There are 5 more un-commented engine trace channels - ECC_EngineTraceChannel2 - ECC_EngineTraceChannel6. Can I use these channels? Are they reserved? Is there a practical difference between using engine trace channels and game trace channels?



Try to use 2 channels for player and 2 channels for vehicles.

Channel1 PlayerNotRiding
Channel2 PlayerRiding
Channel3 VehicleNotRiding
Channel4 VehicleRiding

PlayerNotRiding Block ALL
VehicleNotRiding Block ALL
PlayerRiding Overlap VehicleRiding AND PlayerRiding / Block PlayerNotRiding AND VehicleNotRiding
VehicleRiding Overlap VehicleRiding AND PlayerRiding /  Block PlayerNotRiding AND VehicleNotRiding

and switch collision channel when they mount and dismount vehicle.

If i understood your problem and if i’m not wrong it should work

Thanks for the proposed solution, but this is basically what I’m doing right now (except that VehicleRiding blocks VehicleRiding and PlayerRiding blocks Player Riding).

The problem is that Vehicles and players should always block all other vehicles and players, regardless of whether they are on vehicles or not. The only time two entities should overlap is when a player is riding their own vehicle.

Right now when a ridden vehicle attempts to collide with a player on another vehicle, it has to do an overlap test and come up with a collision response. I also need to do this while a player is getting on or off the vehicle (so they don’t collide with their own vehicle trying to get on/off). That means collision is going to act differently the moment before a player begins getting on a vehicle and the moment after. Even if I manage to get the overlap response to behave just like the hit response, managing the two code paths is annoying and error prone.

With collision layers per-player, I can just respond to component hits and be confident that the physics calculations and collision responses are going to be done properly and consistently.

Edit → Project Settings → Collision