Linerenderer doesn't match my ray.

So I have this code that I am experimenting with, and the inputs and everything works fine, although when I test my Line Renderer, the lines do not match with my Debug.DrawRay test.

Like this: 88192-unity-2017-02-16-16-25-29.png

It gets worse the closer it gets to the origin too: 88193-unity-2017-02-16-16-29-07.png

Here is my code:

void PreJump()
        //Mouse Pos
        Vector3 direction =;
        Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
        if (Physics.Raycast(ray)) {

            //placeholder values
             direction.x = ray.direction.x*50;
             direction.y = ray.direction.y * 50;

        Vector3 top = Calculator.GetTop(gameObject);
        //lr is the linerenderer
        lr.SetPosition(1, top);
        lr.SetPosition(0, direction);
        if (Input.GetKeyDown(KeyCode.Space))
            jumpDirection = direction;
            preJumpPhase = false;

Any help would be appreciated!

You’re setting a direction as the position for the LineRenderer, which only consists of positions. assign positions only (the same as if you were using Debug.DragLine instead of DragRay)