Unity freezes on using ABPath.FakePath()

I am working on a multiplayer game where the characters move from a fixed start & end position on a 2d grid-based map. I use the AILerp script, set the destination & call the search path. And the path can change from what it generated at first.
To sync the character’s movement on opponent side i am using the below code.

//Code to get the remaining path
var buffer = new List<Vector3>();
                    MyAILerp.GetRemainingPath(buffer, out bool stale);
//Code to do the set path
                    var abPath = ABPath.FakePath(buffer, null);
                    MyAILerp.SetPath(abPath);

When i call this first time on character spawn and with the path generated there is no issue and the AILerp did its job. But, when the path is changed/auto recalculated in between, i have used the same code to do the MyAILerp.SetPath(abPath) next time. But i have got StackOverflow exception and Unity is freezing for a few seconds, the build will crash immediately. Please find the settings i am using.

Please someone help me how to fix this.

Thanks,
Avinash Ch

I have fixed the problem. It is one recursive call in my code.

1 Like