Line renderer canvas corner

I’m new here, sorry if this is maybe the wrong place. I am attempting to use a line renderer along with a raycast to make a laser. Ive been consistently running into this issue where the end point of the line renderer defaults to what appears to be the bottom left corner of the canvas element no matter what direction im facing, or position in the scene. Does anyone know why or if this is usual when missing some obvious component?

You can use LineRenderer.SetPosition(Vector3) to set the start and end point of the Line Renderer.

Example Code:

var laserStartPosition = transform.position; //Start point of raycast and LineRenderer
var laserDirection = this.transform.right; //Going in direction of +X axis
var maxLaserDistance = 50.0f; //Max distance of laser

Vector3 laserEndPoint;
RaycastHit2D hitInfo = Physics2D.Raycast (laserStartPosition, laserDirection, maxLaserDistance);

if (hitInfo.collider) {

	//Stop the laser at the position it hit
	laserEndPoint = hitInfo.point;		

} else {

	//Keep the laser going to its max distance
	laserEndPoint = laserStartPosition + (laserDirection * maxLaserDistance);
}	

Debug.DrawLine (laserStartPosition, laserEndPoint, Color.green, 0.10f);//Optional for debugging

//Generate two points on the Line Renderer
lineRenderer.SetPosition (0, laserStartPosition);
lineRenderer.SetPosition (1, laserEndPoint);