How should I make my NPC maintain high ground?

I want my NPC to always try to maintain the high ground

I’m not too sure how I should be doing this.

I’ve tried looking around for devfourms to find a solution, nothing.

I tried to make it so before the NPC moves in it’s target’s direction, it’ll check the waypoints to see if its below the height that the NPC is on right now, can’t really check for the waypoints before the current waypoint, and if I try checking from the humanoid root part, or any bodypart, it would always return as being lower, since waypoints are generated at the very bottom, so nothing from the bodyparts will be on the same Y as the waypoints.

I hope I’ve provided enough information for someone to help me solve this. Thanks for reading.

2 Likes

I would occasionally check a few positions around the NPC that are higher than it’s current position. If a valid path can be found, move the NPC to that point.

You could use the HumanoidRootPart’s xz-position but with the y-value of the current waypoint.

Interesting, I’ll try doing that for sure. If it works out, I’ll mark your answer as the solution. Thanks for responding

1 Like

Hmm, it seems I can’t get this to work. Right now, I’m just making sure before moving towards the target, to check if the NPC is higher then the target currently. That’s about good enough for me. Still, someone might be able to get it working with your method, So I’ll mark it as the solution.

1 Like