How to get the volume of a waterbody(lake)?

For some context I’m making some fish AI and getting them to move with Customizable Pathfinding. the goal is to only get random points that are in lake, currently the fish randomly picking a location to swim to in a box volume until it finds one in water but they attempt to get points that are below the floor a decent amount of the time and sit still until one is found.

Is there a way I can get the volume/area of the waterbody, lake in this instance, to get something like a custom bounding box?

I found this video that could work but i would like more accuracy in the volume bounds https://www.youtube.com/watch?v=3_A7WTIo9Ws

The approach you’re describing is usually used for patroling enemies or NPC’s roaming in a city. If you want a fish swimming aimlessly in a sea, why don’t you have it swim straight and change direction when it’s about to hit something? You could also randomly change it’s direction occasionally to make it more natural. This would be a better way to achieve your goal in my opinion.

I wanted the fish to eventually favor different depths, find food, favor swimming near others of its kind. But you’re right just changing the direction is will be enough, I’m already doing line traces and can just check if the next location will be in water.

You can always override what I said when certain requirements are met and achieve those behaviors you want :blush:

Also, there weren’t any location calculations in my suggestion. You’d only need a short line trace that starts from the fish’s location and a little bit further to determine if it’s about to bump into an obstacle or get out of the sea. (You can place an invisible barrier with no collisions on above the sea and include that to the trace channel your line trace is set to block)

I gotcha, I believe I understand what to do thank you!

1 Like