Search Unity

Raycast only layer

Discussion in 'Physics' started by sickb0y247, Nov 2, 2015.

  1. sickb0y247

    sickb0y247

    Joined:
    May 29, 2014
    Posts:
    54
    Hello my unity brethren. I know there's a layer for ignoring raycast but is there a way of making a layer that only collides with raycasts? Since the raycast layer isn't actually in the checkbox menu I can't simply uncheck all of the other layers except for raycast like I would want to do. Any help here would be much appreciated.
     
  2. sickb0y247

    sickb0y247

    Joined:
    May 29, 2014
    Posts:
    54
    bump. Anybody got any suggestions?
     
  3. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    This is a question that actively fights Unity's design. You will have a much easier time doing it the Unity way and it's worth changing your code around. What you should really be doing is using the mask parameter of the raycast to selectively control it.
     
  4. sickb0y247

    sickb0y247

    Joined:
    May 29, 2014
    Posts:
    54
    But from what I can tell "masking" raycasts is all about telling the raycasts what colliders to ignore. I don't want the raycasts ignoring anything at all. I want all of the other objects to ignore this object EXCEPT for raycasts. Aha ok it's working for me now. I can in fact uncheck collision with all of the layers and it still detects raycast collision. Probably should have tried this sooner but I assumed it wouldn't work. Thanks for the reply though!