AIPath with Account For Slopes

Hi @aron_granberg

I have a character in my game that the player controls by clicking somewhere in the world, fairly basic RTS movement. All of this happens on a grid graph where I have the ‘accountForSlopes’ variable active as there are slopes in my game.

What I’m working on now is that the player can have a pet that simply follows the player around with a slight offset. Right now I solve this by using the AIPath component with a ‘endReachedDistance’ of 1 to be slightly behind the player at all times and simply setting the ‘target’ of the AIDestinationSetter to the moving transform of the player. This works great so far. But as soon as the player climbs up a slope, which makes it ‘Y’ change the pets ‘Y’ remains the same and it dissapears in beneath the terrain the actual player has been elevated to, the ‘X’ and ‘Z’ are still correct.

I’ve also tried the AIPathAlignedToSurface component, but it didn’t change anything. Any suggestions for this case?

Sounds like your pet doesn’t have the gravity layer mask set to include the terrain layer.

1 Like

Hi, thanks for the quick reply.

This already helped a lot, but it kind of only works when approaching the slopes from the front. If I move onto them from the side the pet does not path over them, but tries to do it directly, making it fall off my map. For this I tried the ‘constrainInsideGraph’ variable, but that than caused issues with getting on the slope agian.

Might there be a possibility to use the AILerp script instead, as this is the one I’m using on the player and it doesn’t have any issues, but with the addition of a slight follow offset?