LineRenderer behaving strangely

Hope someone can help with this. I’m trying to have my line renderer follow the same path as my debug.drawline. I’m using the same vector set with line renderer WorldSpace box unchecked, but for some reason the line always moves up the same magnitude as the object the line renderer is attached to on the y axis. Pic attached for clarity. The green line is the debug.drawline, the pink is the line renderer, the box has the script attached to it.

6777467--783956--Example.PNG

void DrawPath()
    {
        LaunchData launchData = CalculateLaunchData();
        previousDrawPoint = ball.transform.position;

        int resolution = 50;
        for (int i = 1; i <= resolution; i++)
        {
            float simulationTime = i / (float)resolution * launchData.timeToTarget;
            Vector3 displacement = launchData.initialVelocity * simulationTime + ball.transform.up * gravity * simulationTime * simulationTime / 2f;
            drawPoint = ball.transform.position + displacement;
            Debug.DrawLine(previousDrawPoint, drawPoint, Color.green);

            //LineRenderer
            lr.enabled = true;
            lr.positionCount = resolution + 1;
            lr.SetPosition(i, drawPoint);

            previousDrawPoint = drawPoint;
        }
    }

To me that sounds like you SHOULD have world space checked… right?

Drawline takes coords in world space, and you said you’re feeding the same coords to the LineRenderer…

1 Like

Hi, Kurt. Thanks for the suggestion. I tried that initially, but with really odd results. I have the object the Linerenderer is attached to as the child of another object, so all the coordinates are being processed in local space. Whenever I have the Use Worldspace option checked, it anchors the object to it’s transform coordinates in world space, no matter where the parent is moved. This doesn’t work for me since I need the Linerenderer object to move with the parent. Pic attached for clarification.

6779504--784529--Example.PNG

Here is the resulting line drawn when Worldspace is checked.

6779504--784532--Example2.jpg