0

I am willing to raycast specific layer and ignore other layers no matters its colider is above to my navPoint layer object?

 int specificLayerMask = LayerMask.GetMask("NavPoint");//raycast only this layer ignore others

        if (Physics.Raycast(raycastObject.transform.position, fwd, out objectHit, specificLayerMask))//50
        {}

the above code raycasting to navpoint layer but unable to bypass other layers colliders. is there any way available to ignore all other collider and raycast to desired layer only no matter colliders are behind any other collider

Keiwan
  • 8,031
  • 5
  • 36
  • 49
Muhammad Faizan Khan
  • 10,013
  • 18
  • 97
  • 186
  • 1
    This is a pretty comprehensive answer on raycast and masking: https://stackoverflow.com/questions/43559722/using-layers-and-bitmask-with-raycast-in-unity – avariant Apr 22 '17 at 14:02
  • its strange that my question is duplicated while the suggested question has asked on hour ago! – Muhammad Faizan Khan Apr 22 '17 at 14:44
  • @avariant that is fine but its not good. i have asked question so answer must be given to me but programmer asked this question 1 hour ago and answer it own. This is not the right way to gain reputation – Muhammad Faizan Khan Apr 22 '17 at 14:45
  • Your question is already a [duplicate](http://stackoverflow.com/questions/31920743/raycasting-only-to-a-particular-object). I've seen and answered similar questions all the time and just decided that if I provide a way to include, exclude objects, that would reduce the chances of people asking this question over and over again. I modified the duplicated links to include the first [duplicated](http://stackoverflow.com/questions/31920743/raycasting-only-to-a-particular-object) question. – Programmer Apr 22 '17 at 15:19
  • FYI, you can mark a question as a duplicate to another new/old(doesn't matter) question if that answer is more detailed than the other answer. This is what happened here. – Programmer Apr 22 '17 at 15:24

0 Answers0