How would I make an AI that can wander across hilly parts?


I want the AI to get random points to walk to. (Assuming all points are reachable)

2 Likes

Hello,
you could try checking this Guide which uses the PathfindingService.

2 Likes

Yeah but you need to input a position for it to generate keypoints for the ai to walk to, which is the problem

Ah, so you want AI that moves around area randomly if I understand you correctly?

Yes, but the area isn’t a flatplane which makes it difficult

Not really, you could generate a random X, Z position in the plane and the fire a raycast from the sky to get the ground height (Y) and then path the the the X, Y, Z.
Keep in mind this might affect performance with large numbers of NPCs and you could pre-bake the results by firing the Raycast in Studio every ~0.1 studs and then storing it in table, later you would just look the nearest point up and use that for the Y.

1 Like

My game has a large number of NPC so this might not be the most performant solution, I’ll try to think of a more performant one

1 Like

Then you can do this as I said:

Do the raycasting in the Studio and after that store the results somewhere like this

{
 [x, y] = z
}

and find the closest match from the table instead of raycasting.

2 Likes

Hmm okay, I’ll try that

Message too short

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.