Visualizing rays with Debug.DrawRay()

Not extremely useful but it looks nice.

You can hook it up in RaycastForLayer():

if (hasHit)
        {
            Debug.DrawRay(ray.origin, ray.direction * hit.distance, Color.yellow);
            return hit;
        }

BTW if you want to add one more layer to check in the CameraRaycaster script, don’t forget (like me)
that the layerPriorities array has already been serialized in the editor with size of 2! If you don’t update that size in the editor, you new layer will be completely ignored.

Privacy & Terms