Support Forum

How to use GetTotalLength() function?

Hello, I want to GetTotalLength() from ABPath.

Here is part of my code

                var pathAB = ABPath.Construct(transform.position, tile.transform.position);
                List<Vector3> vectorPath = pathAB.vectorPath;
                float ilosc = pathAB.GetTotalLength();
                Debug.Log("Total length: " + pathAB.GetTotalLength());
                Debug.Log("Total length v2 : " + pathAB.vectorPath.Count);
                Debug.Log("Total length v3 : " + vectorPath.Count);

It turns out 0 in Debug.Log :frowning:

Could someone give me an example code how to use GetTotalLength() function? Even shortest from the short will be okay, I want to learn how to use it properly.

The path has not been calculated yet.

You can either wait for the path to be calculated or force it to calculate immediately using path.BlockUntilCalculated().