Areas with variable penalty/bonus


#1

Hello!
Is it possible to have a bonus/penalty in an area based on the direction the AI wants to go?
I use currents that sweep away everyone that’s inside towards a certain direction…
What I want is the AI to AVOID passing through them if it’s gonna sweep it AWAY from it’s destination,
and WANT to pass through them if it’s gonna sweep it TOWARDS it’s target.

I guess I could check for the Vector2.Dot(2D btw) each frame and update the penalty
–but what about a bonus, other than adding a penalty to every other region?


#2

I guess I could check for the Vector2.Dot(2D btw) each frame and update the penalty
–but what about a bonus, other than adding a penalty to every other region?

To be honest I just thought of this while typing my question down :sunny:! But thought I’d post anyway.
Any tips on how to do what I want to do would be great :smiley:


#3

Hi

This is not possible out of the box, however you could modify the GridNode class to use different connection costs for different directions. Make sure that you only increase the cost from the standard one however, don’t decrease it because then the pathfinding algorithm may no longer generate an optimal path (for more details see https://en.wikipedia.org/wiki/Admissible_heuristic).