Search Unity

Different Layers On Object - Is This Possible?

Discussion in 'Physics' started by JasonBricco, Mar 24, 2015.

  1. JasonBricco

    JasonBricco

    Joined:
    Jul 15, 2013
    Posts:
    956
    I couldn't think of how to word the question exactly as I wanted to. Here's what I want to be able to do:

    Let's say I have an object with a mesh composed of two submeshes. I build this object to use a mesh collider. However, the mesh collider is only supposed to apply to one of the two submeshes, since the player should be able to collide with this mesh. The other submesh I do not want the player to be able to collide with.

    So, when I build the mesh collider for this object, I don't add any vertices and triangles from the submesh that should not be collided with.

    The problem is, while I don't want the player to collide with this second submesh, I do want to be able to raycast against it. Without the colliders, I can't raycast against it. And with them, the player also collides with it.

    Ideally, I'd like to be able to say that the second submesh is on a layer that the player (and everything else except raycasts) ignores for collisions. Only raycasts should be able to hit it. I'm thinking isn't possible, though.

    My question is: Is there some relatively simple way to get around this, or am I going to be writing my own custom raycasting system?

    Thanks!
     
  2. JasonBricco

    JasonBricco

    Joined:
    Jul 15, 2013
    Posts:
    956
    Ended up writing a custom raycasting system.