Search code examples
c#unity-game-enginecollider

Multiple Colliders - How to make a collider invisible to certain objects


Basically I have teleport zones set up to access new areas within the level. This is only supposed to respond to the player's box collider. However, I attached a cube to the player, disabled the mesh render and use its collider to detect enemies. Unfortunately, the detect enemy collider touches the teleport zone and warps me to the new position well before my player gets near it. I tried to change the tag on the enemy detection collider but it still teleports.

How do I go about making the teleport object ignore the player's enemy detection collider?

I'm using Unity 5.3.8 and C#


Solution

  • Change player's GameObject layer to Player. Then, create a new layer called Teleports. Go to Edit -> Project Settings -> Physics. Then, under Layer Collision Matrix, in Teleports row uncheck everything except for column under Player.

    Now, objects in Teleports layer will only collide with objects in Player player.