GetNearest return wrong Point

Hello Aron! I have a one problem. I need to Character walk to the closest available point near.
I send to GetNearest a center point of the object. I want to get the closest walkable node. But method return same point and character stuck.
How to fix this?

For example, on these screenshots object position is (81.43, 11.69, -40.91). I try to get a near grid node position, but I see a same position (81.43, 11.54, -40.91). Only Y axis changed. But i see, on this point i don’t have a walkable nodes.

In vacuum all works, i create cube and place this code in update void, and all works, but for my game logic it works incorrect.




Through experience, I realized that during the first call, for some reason, the method returns incorrect data. The method returns data without a name at all. But 1 time.

All work correctly after frame skip. Maybe its this is related with graphMask changes.
After i change graph mask A* need one frame skip to calculate real position.
What is this connected with?


Are you sure the graph is scanned when you query it the first time? Are you doing any graph updates?
You should not have to wait after changing the graph mask.

Yes, I’m sure, since I’m making these requests in the first frame of the game.
Afterwards, I use the mouse to select where the character needs to go. And when switching graph masks, for some reason you need to wait for a frame.
I don’t update graphs or do any calculations, I only use the basic API.


Are you really sure you are not doing anything else besides changing the graph mask? Because the NNConstraint doesn’t influence anything else. There shouldn’t be any state that it has to wait for after updating its graphMask.

To be clear, you are saying this happens even later in the game, not just the first frame?

1 Like