I searched for topics which could help me, but I don't find anything that fix my problem.
I'm using RayCastAll to get a list with colliders touch the ray, but I need ignore some layers and I having problem with it.
public LayerMask ignor;
public Transform Player;
private void Update()
colid = Physics.RaycastAll(transform.position, Player.position, ignor);
for(int i = 0; i < colid.Length; i++)
if (colid[i].collider.tag == "Player")
Debug.Log("I'm seeing him!");
The objects on layer ignor are detected yet, and I don't know why. Some help?
Answer by Commoble
Mar 19 at 08:41 PM
The documentation for RaycastAll is poorly worded. Your layermask should include the layers you want the raycast to hit, not the layers that should be ignored.
It is interesting, but still not working...
Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.
The best place to ask and answer questions about development with Unity.
To help users navigate the site we have posted a site navigation guide.
If you are a new user to Unity Answers, check out our FAQ for more information.
Make sure to check out our Knowledge Base for commonly asked Unity questions.
If you are a moderator, see our Moderator Guidelines page.
We are making improvements to UA, see the list of changes.
Answers and Comments
7 People are following this question.
Multiple Cars not working
Distribute terrain in zones
How to Get Input form HoloLens Clicker
Creating slider menu for selecting an option using scroll view unity?
How do you flip the bullet trail prefab, so it shoots the way you are facing and how do you make the bullets disappear when they hit a platform?