#Laser, LineRenderer and RayCast2D

1 messages · Page 1 of 1 (latest)

flint plover
#

lineRenderer.SetPosition(1, new Vector3(hit.distance, 0, 0));
This line assumes that your LineRenderer's points exist in local space.

lineRenderer.SetPosition(2, new Vector3(reflectionHit.point.x, reflectionHit.point.y, 0));
For this line to work however, your LineRenderer's points need to use world space.

You cannot mix those approaches; choose one (usually world space is easier) and stick with it.
Once you figure that out, making a laser bounce off objects should be pretty simple; you could even write it in a more generic way.

You also may want to keep the logic of your laser and the logic for its movement separate, but that's not related to your problem.

pliant cradle