Search Unity

Make a collider collide with an object but not vice versa?

Discussion in 'Physics' started by NautilusCo, Dec 10, 2019.

  1. NautilusCo

    NautilusCo

    Joined:
    Jan 31, 2017
    Posts:
    5
    So I have two gamobjects with colliders, in this case an ammo box and a player, and I want the player to collide with the ammo box, i.e. they have to walk over it rather than through it, and I want the ammo box to still have physics and collide with the floor, but I don't want it to collide with the player, i.e. the player knock it over. As far as I can tell, with the collision matrix and things like Physics.IgnoreCollision you can only make it ignore collision both ways, rather than just one. Does anybody have any idea if this is even something that can be done in unity?
     
  2. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    11,455
    Collisions are not directional. When two colliders collide, it's a single contact of the pair. Just because one moved causing a contact doesn't make that a direction. In a lot of cases two can move.

    You can use a collider for the collision with the ground and another collider (set as a trigger) on a child GameObject that is set to contact the player (presumably for collection).