Question by
silverxah · Jul 25, 2016 at 10:58 PM ·
raycastlinerendererraycasthitlaser
Raycast Getting Caught
So I have a script using a raycast and linerenderer to basically act like a laser pointer originating from below the camera. What I want is for the pointer to not go through objects. However, the problem with my collider script is that whenever I rotate the camera past an object, the line gets "caught" as in it gets stuck on the side of the object and doesn't continue forward. The collider script is attached below. Any ideas as to what I should change?
if (Physics.Raycast(lazor, out end, Mathf.Infinity)){
if (end.collider.tag == "Object")
lines.SetPosition(1, lazor.GetPoint(end.distance - 1));
} else
lines.SetPosition(1, lazor.GetPoint(100));
Comment