330 is just way to little even when i optimise my search i will still need to increase this number to at least 2000 at later stage
technically i am following Dijkstra pathfinding algorithm with some twist i dont have nodes i just use coordinates and i create a string chain the npc can walk along “www” would walk the npc 3 tiles upwards
currently i havent found a solution for this issue
so the help of a wise guru would be very welcome
how can i increase the limitation of recusrive calls allowed? 330 causes no lags or noticable delay so i am not fryn my machine
or is there a tricky way to avoid running in stack overflow, i tryed calling a new method after 300 calls which basicly continues where i left just to run in the same issue around +30 calls
I’ve done grid based searches plenty of times. I would ask Chat GPT to show you how A* pathfinding on a grid of nodes works and convert your system to use nodes.
You’re probably allocating many new objects in memory in each recursive call that are not necessary. For example, I see that you’re using RaycastAll, that allocates a new array each time. You should substitute it with RaycastAllNonAlloc.
Worth adding that whenever you hit a problem with recursion depth, there is always a way to rewrite your code non-recursively. Typically this involves using a Stack data structure that essentially replaces the call stack. You push and pop items to and from the stack as you start and finish considering them, but you do it in an iterative loop, so you are no constrained by the call stack size. But in this specific case, A* is probably the way to go as @davidlovegrove said.