Can`t make Line from Object to center of scene

Hello, I got this problem. I wanna make a laser from object to center of the scene, and if the object moves, the laser also moves. I wrote a code:

private LineRenderer laser;
    void Start () {
        laser = GetComponent<LineRenderer>();
    }
   
    void Update () {
        laser.SetPosition(1, - transform.position);
        laser.SetPosition(0, Vector3.zero);
    }

and this laser goes in right direction, but too far:


How can I fix it?

Make sure the LineRenderer’s “Use World Space” checkbox is ticked.
You also most likely don’t need to set position 0 every frame since it’s not supposed to move anyway.

1 Like

Thank you, it is very helpful :slight_smile: