I'm building a simple 3D scene with following structure:
I want to use Navigation.getsimplepath() to provide the BadGuys a route to the player through a map. Initially I simply put a timer for each BadGuy to call Navigation every 2 seconds, but it lead to mini freeze every 2 seconds, as it takes more than 100ms to process.
I quickly realized, that I need to calculate path on a thread and send the results to BadGuys. I've done that and performance is now great without any annoying stuttering.
But since I've made this change I keep getting random crashes and hangs with 100% CPU Load. I thought, that I made some not thread-safe operation so I spent days trying to fix this using mutex, call_deffered() functions, many individual threads, one AI-Overlord thread, but nothing makes my game stable.
Are there some examples of how to properly call getsimplepath() on Navigation Node from a Thread and send results back to another Node? I'm stuck!