I need help making NPCs drink water

So I have a bunch of animal NPCs in my project. These guys need water right? I have lakes and rivers where they can drink. Problem is I don’t know how to generate the location they should go to when they are thirsty. I tried creating a handful of locations on the shores and randomly choosing one but they always end up overlapping on one eventually:

What I’ve thought of doing: Manually creating a whole lot of points along the shores and saving them all in an array. Each element will have a boolean assigned to them which will determine if the spot is already taken by another animal or not. Make a Task in the BT which will return the nearest drinking spot that isn’t taken.

Is this a good idea? If it is, what aproch would be best to implement it?

1 Like

hi, interesting gameplay.
what you described sounds like a good idea.and you seem to answered your own question…

to implement it you could try the following:

create a task called “get drink location”.

in that task:
1, get all actors of class (target point actors that you placed in the level earlier).

2, for each loop to check if they have the Boolean marked to true.

3, add every actor that doesn’t have the Boolean mark to true to a new array.

4, use a “get nearest actor” node to get an actor from that new array.(this one would be it)

5, mark the chosen actor’s Boolean to true.

Could you create a custom property on your land tiles/or terrain objects to specify it is drinkable, then use A* pathing to get to the nearest drinkable tile?