Lag spikes because of AstarPath.Update() in Profiler

Hello, I have little problem and I don’t know really how to solve it! :frowning:

I included picture because I think picture tells 1000 words. Even a little hint would be cool (how to optimize this etc)

Hi

Those lag spikes come, as you seem to have noticed, from the DynamicGridObstacle script. However it has nothing to do with your flyer being in the shape of a capsule, it could be any type of collider. Updating a graph is relatively slow and it increases with the number of nodes you need to update.

I am not sure why you need two grid graphs in your scene, and why the horizontal one has such a high node density. Could you possibly reduce it?

PS: Other general performance tips, get rid of using OnGUI, OnGUI is SLOW (apparently it takes about 3.51 ms per frame in your case).

Hello, the vertical grid graph is for navigation ( so player knows where is his target platform (in case of walls it is helpful, and Astar is also perfect for that).

Horizontal grid is high res because it needs to be, so NPc can find its way into cave ( it is buggy if low res I think). Will try to set it to lower resolution.

And hey by the way, isn’t so that only those nodes that are changed are updated and not whole graph? (as I saw in code, old bounding box and new bounding box)?

OnGUI is slow because it draws whole GUI, and it kinda works cool in this case. Also I already build whole GUI system with it… But hey, I only use single OnGUI function call per frame :).

Also, If I buy Pro version, will it be faster? I need to run this game on low end mobiles (single core, that is) on at-least 30fps.

And let me say, thank you for your time, it really is life saver, because I am kinda lost in this. I think I will have to convince our boss to buy this addon because we will need multi-layered grid graph anyway!

Hey, lowered the resolution of horizontal grid and maybe little improvement (like 4-6ms lower) so instead of 16ms it is 12ms. Hmm…

Hi

In this case, the pro version will not be faster.
Do you need a DynamicGridObstacle to update the graph at all times, or could you just update the graph when the helicopter has landed?

Hello, I think that DynamicGridObstacle is really overkill in this case and that Obstacle avoiding can do just nice, no?

Also thanks for your efforts :smiley: