- Home /
Other
How do i make my own ignore raycast user layer?
Hello! I am trying to make an ignore raycast user layer. How do i do that? Or. Is it even possible? I'm new to raycasting..
Answer by MostNimbus · Mar 26, 2017 at 08:39 PM
You mean, you need a raycast that ignores player?
If you're new to that type of thing there is the solution:
Create layerMask variable
Go to Edit->ProjectSetting->Layers and tags
Create a layer, assign it to your player gameobject. (You can find object's layer at top of inspector, under the name field)
Get your layer number and do
layerMask = ~(1 << 8);
Then, use your layermask in raycasting:
Physics.Raycast(position, direction, Hit, Range, layerMask)
That should work.
Follow this Question
Related Questions
Raycast ignore layers except 1 Answer
Strange 'Glitch' while trying to apply the built-in layer "Ignore Raycast" via code 0 Answers
Layer Mask Detection 2 Answers
Detecting that I'm clicking a unit even though I'm not? 0 Answers
LayerMask for RayCast 1 Answer