- Home /
Raycast to an object behind another object without ignoring raycast
I want to Raycast to a plane which has many objects on it but want the raycast to pass through those objects. However, I want to use OnPointerEnter and OnPointerExit on those objects (to reduce their alpha and make the part of the plane behind them more visible) so I cannot add them to the Ignore Raycast layer. How do I go about doing this?
you could use raycastall which returns everything that is hit. and simply check for the name of the plane. https://docs.unity3d.com/ScriptReference/Physics.RaycastAll.html
Answer by hexagonius · Mar 11, 2017 at 07:51 AM
If it's they one collider explicitly, you can do a.
collider.Raycast();
where collider is any collider type
That is a good Idea, but what if I am using a custom Raycaster ( which is the case with me )? collider.Raycast() uses the default physics raycaster right?
Answer by tanoshimi · Mar 11, 2017 at 10:03 AM
Not sure what you mean by a "custom raycaster", but if you want a raycast that continues through all colliders in its path rather simply returning the first collider hit, you can iterate through the array returned by Physics.RaycastAll.
Your answer
Follow this Question
Related Questions
Raycasting vs. events 0 Answers
Raycasting not working on all sides? 1 Answer
Ray is not being detected 0 Answers
ScreenPointToRay not responding 0 Answers
Strange 'Glitch' while trying to apply the built-in layer "Ignore Raycast" via code 0 Answers