Use trigger with player but have a collider with everything else?

Hi, I have a crate that uses a trigger to detect when the player hits it. Is there any way I can make it collide normally with all other objects? My player has a tag ‘Player’. Thanks.

I would nest a game Object with a collider of the same size inside the crate. Set the original collider to “isTrigger = false” and the new object inside the create to “isTrigger” So it would be like having 2 boxes, one is invisible but has a trigger that is inside the visual box. Tell the player to physics.ignoreraycast the collider on the visual box and bingo.

I would suggest a Layer-based ignore collision method. Place 2 colliders on top of each other. 1 is marked as a trigger, the other is solid. Create 3 layers:

-Player (layer the player in this one)
-PlayerOnlyTrigger (for the trigger)
-Collider (the regular collider)

Obviously naming can be changed, but its just the idea of it.

Now go to the Physics settings, “Edit/Project Settings/ Physics” And you’ll see the layer collision matrix.

  • Turn player on for EVERY layer EXCEPT COLLIDER:
  • Collider is true for EVERY layer EXCEPT PLAYER (The first bullet point should also do this for you.)
  • PlayerOnlyTrigger is false for EVERY layer except PLAYER.

Then work out your game logic as usual. In the OnTriggerEnter() you don’t have to worry about checking if its the player either because you can only collide with the player anyway.

Good posts! I had this problems too, the solution I used was to:

  1. Create a MESH Collider on the gameobject with isTrigger DISABLED, then the gameobject is solid, and you can’t walk through it.

  2. Then I added a BOX Collider on the same gameobject and set isTrigger ENABLED.

Now the BOX collider will trigger any script with functions OnTriggerEnter and OnTriggerExit.