Support Forum

Movement Speed and Penalties

Hi :slight_smile:
I’ve been through the documentation a couple of times now but I feel like I am overlooking something.
I have a hex grid with grass and forests. I understand that I can give both layers a penalty, which will make it more of less likely of the seeker to choose a certain path.
But if I not only want to deter the seeker from choosing a path, but also want to influence its speed - how would I go about that? The penalty doesn’t (as far as I understand) change the speed, but make it more or less probable it will take the route, so there ought to be some other functionality for that, I guess? Or would that be some kind of “Seeker checks ground it is walking on → sets speed to whatever variable ground offers for that”?

Depends on the AI but for RichAI i just changed the max speed based on the surface they are on. The surface they are on was tracked separately from recast as recast doesn’t really know this.

I think that’s actually the point I am looking for: Is “check ground for (modifier to) speed variable” something this A* has build in somewhere, or do I have to handle that separately? I’m not opposed to writing my own code for that, I’m just working for the first time with pathfinding and thought this was some kind of “typical behaviour” that could be handled in a more elegant way than I could come up with with something already build in (and I’m just too new to this topic to have found by now).

Adding later: I was able to find a way to get this to work via this Tutorial: How to store data in tiles (Unity Tilemap + Scriptable Objects) - YouTube . It’s not about the A* project, but the functionality can very well be adapted.

Hi

Sorry for the late reply.
There is no built-in way of doing this, but you can easily do this from a separate script:

var ai = GetComponent<IAstarAI>();
var node = AstarPath.active.GetNearest(ai.position).node;
ai.maxSpeed = do something based on either node.Tag or node.Penalty