Skip to main content

RaycastReflection

A class in Root.Township, the global namespace.

Debug script that draws a laser bouncing off surfaces with a LineRenderer, logging the name of every object hit each frame.

Constructors​

MemberWhat it is
RaycastReflection()Unity makes components itself; use AddComponent or spawn a prefab instead of new.

Fields​

MemberWhat it is
int nReflectionsHow many bounces to trace, at least 1.
6 private and internal fields
MemberWhat it is
private Transform goTransformCached transform.
private RaycastHit hitLast raycast hit.
private Vector3 inDirectionCurrent reflected direction.
private LineRenderer lineRendererLine renderer that draws the path.
private int nPointsNumber of points set on the line.
private Ray rayRay being traced.

Methods​

2 private and internal methods
MemberWhat it is
private void Awake()Caches the transform and line renderer.
private void Update()Raycasts forward, reflects up to nReflections times and sets the line points, with debug rays and logs.