# How to disable player-player/player-monster collisions and keep the OnTrigger/OnCollision hooks?

I'm developing a network game. Players and enemies have attached Rigidbodies, move with physics forces, stops on kinematic colliders (walls) - everything works pretty well. Now it's the time for player-player and player-monster coliisions.

In my case, the player should be unpushable, even by other players and monsters.

The problem with that is if all 'moving/non-kinematic' objects have rigidbodies, they can move/push each other as they move - which is wrong in my case. I came up with an idea that I'll disable collisions between these objects through layers and did that.

I also wrote a script which pushes the object back (in the opposite direction) when triggered which I want to apply.

The problem is here, that I need to preserve the original collider (non-trigger) so the player can be stopped by walls AND I need to detect other players in OnTriggerEnter() so I can push them back so they don't overlap.

This is quite easy - I need two colliders attached to the player:

• a non-trigger one - responsible for the ground, walls, physics driven

• a trigger one - for interaction with players and enemies (to push them)

I also need to disable built-in collisions between players through the physics layers and listen for "Player" and "Monster" tags in OnTrigger().

Does this all make sense? How would you improve this? Is there a quicker way to achieve this? Two colliders seem not that bad - but it's still two instead of one.

In order to visualize what I want to achieve:

Games I know have collisions like this are Diablo 3 and League of Legends probably.

• Did you profile? Is it a bottleneck? The tone of your question implies you are trying to do premature optimization. – S. Tarık Çetin Jul 8 '17 at 15:03
• To be honest, I'm trying to figure out how to implement this, so it will be clean and easy to adjust/edit. As this is a popular scenario and I couldn't find anything similar, I'm asking for an advice. – Jacob Jul 8 '17 at 15:13
• Did you actually achive this or not? I understand from your question that you already have a system working. – S. Tarık Çetin Jul 8 '17 at 15:33