- Home /
can i make a raycast only detect one collider? C Sharp
Hey, so i want to use a raycast to place an object on the mouse position, bot only on the ground, despite there is an object in the way. for example i would like to place an object behind a tree, on the ground, could i make it so it only detects the ground and does not stop at the tree?
Answer by robertbu · Oct 28, 2013 at 01:10 AM
The easiest and most efficient way to do this is to use Collider.Raycast(). This will raycast using a specified collider only. An alternate solution is to put the ground on a separate layer and use a layer mask in the Physics.Raycast().
Your answer
Follow this Question
Related Questions
Weird Rayscast-Distances 1 Answer
Determine object hitting a static collider at update() 1 Answer
Picking up few different objects 0 Answers
SphereCast Arguments 1 Answer
Debug.DrawLine problem 1 Answer