I'm Trying To Make Fish That Randomly Swim Around - How Should I Do This?

Hello! A game of mine happens to have a lake, and I think it would be cool do have little fishies that swim around randomly. What is the best method to do this? BodyVelocity/BodyGyro? TweenService? And how do I keep them in the water? (I use terrain water)

I am leaning towards a solution that is a combination of low-lag, non-repetitive, and functional; Simply having them swim in circles would be the easiest option, but I’m looking for a way to make them swim like fish really would.

Not sure if this is the right category; Sorry if it’s not!

2 Likes

you could use MoveTo

if there is a wall then use

PathFindingService

Sample code

Fish:MoveTo(BeforePos.Position, Target)
2 Likes

If you are willing to take a complicated approach to this, you could check out boids.

3 Likes

If these are purely for decoration, do it client side, and only have the fish appear when the player is somewhat close to them. I would advise turning off physics for the terrain water and making your own water scripts, as that will make cases like this very simple. If you insist on using the default water physics, then consider fiddling around with BodyPosition for movement. I bring it up because BodyPosition is less vulnerable to random noise than BodyVelocity.

2 Likes

Follow-up: I made a simply server-side script for each fish that comes up with a destination and uses CFrames/BodyVelocity to get there

1 Like