- Home /
How do I make a laser pointer?
I am making a top down shooter and I would like to know how to make a laser pointer. I currently have a directional light, but that only shows where it hits, I want it to light up it's whole path in a small beam.
I actually want what you originally had. A light that shows where it hits without going through the object. You said directional light. Did you mean spot light? Could you say how you achieved it.
Answer by 3dDude · Aug 25, 2010 at 01:54 PM
maybe the code would be like this?:
function Update () { var lineRenderer : LineRenderer = GetComponent(LineRenderer); lineRenderer.useWorldSpace = false; lineRenderer.SetVertexCount(2); var hit : RaycastHit; Physics.Raycast(transform.position,transform.forward,hit); if(hit.collider){ lineRenderer.SetPosition(1,Vector3(0,0,hit.distance)); } else{ lineRenderer.SetPosition(1,Vector3(0,0,5000)); } }
@script RequireComponent(LineRenderer)
and use a texture like this
Answer by qJake · Aug 25, 2010 at 02:12 AM
I think you want a Line Renderer.
How do I make it stop when it hits an object, eg wall?