- Home /
Question by
LeftyTwoGuns · Jul 30, 2014 at 07:25 PM ·
linerenderer
Render only the second point of a Line Renderer?
I'm using a line renderer as a laser sight on a gun, but rather than a laser sight, I'd like it to just be a red dot. I have the second point of the line rednerer set at the hit point of a raycast through script, so is it possible to only render that point of the line renderer, rather than the whole line?
Here's the script if it helps:
public class LaserSight : MonoBehaviour {
private LineRenderer lr;
// Use this for initialization
void Start () {
lr = GetComponent<LineRenderer>();
}
// Update is called once per frame
void Update () {
RaycastHit hit;
if(Physics.Raycast(transform.position, transform.forward, out hit)){
if(hit.collider){
lr.SetPosition(1, new Vector3(0,0,hit.distance));
}
else{
lr.SetPosition(1, new Vector3(0,0,5000));
}
}
}
}
Comment
For a dot, render a Quad with a dot texture billboarded with the camera or aligned with the mesh. Or possibly a small sphere . A LineRenderer is not a good choice.
Your answer

Follow this Question
Related Questions
Top down shooter: Laser Sight 1 Answer
line renderer help 1 Answer
how change linerenderer with png or material.... 0 Answers
Creating a LineRenderer: its always null 2 Answers
create Gizmos such as a wire sphere or line in Update Function 1 Answer