unity – help with path generation


I am trying to build a path for my game and I have a problem
when I am looping through and drawing lines from the current position to the next position the code works but it gives an index out of range exception error, help me with the error, Thanks.

private void OnDrawGizmos()
{
    for (int i = 0; i < curve.Count; i++)
    {
        if (curve[i] == null) return;
        Gizmos.color = Color.yellow;
        Gizmos.DrawLine(curve[i].position, curve[i + 1].position);
    }
}



Source link

More To Explore

Share on facebook
Share on twitter
Share on linkedin
Share on email