Alright so i was looking to update the graph so my moving enemy would be a non walk area for the agent.
When i look in the documentation i see this information: AstarPath.active.UpdateGraphs (ob.collider.bounds);
This looks good but the problem is that the collider2D object dose not have a .bounds structure.
How could i update the graph constantly so the graph keeps up with my walking enemy?
The unity forums tells me Collider2D.bounds is scheduled for the next unity release, until then you can fake it by just doing something like Bounds b = new Bounds ( transform.position, new Vector3(1,1,1));
That will create a bounds object with a size of 1 around the current position.
Great answer thank you!
Is it ok to run UpdateGraphs like every 0.1 second? will this hurt performance alot?
I see the grid is blinking alot, but when i used AstarPath.active.Scan() it dident.
But i heard that Scan is bad to run all the time.
What do you think?
During the frame that the graph is updated, the graph is not shown because it might be incomplete during the update, that’s when it blinks. Scan is a blocking operation so it will not cause blinks.
Every 0.1 seconds is quite a lot. It depends on how many agents you have and how high a throughput you need. Especially when using multithreading, there is a some overhead involved because it needs to stop all the threads, then update the graphs, and then start the threads again, during that time, the pathfinding threads will be idle most of the time and the throughput will be greatly decreased.
Profile and see if it does affect the performance significantly and also check how quickly the character(s) responds to path recalculation requests. Even if it the CPU overhead is not that big, the throughput of the path calculation might have been reduced a lot because a lot of the time the pathfinding threads are just idling.