# Simulate physically-accurate fish swimming in water

I would like to develop a simulation/video-game of some fish swimming in water. This simulation needs to have real time performance and the fish movement should be as physically accurate as possible. I'd like to have 50~100 fish, each around 10~50cm long and the water they swim in should be a square/round pool with a side/diameter of ~1,000cm (10m).

I'm a assuming that a full scale fluid dynamic simulation would be too heavy for a real-time video game. But I'm willing to give up some features:

• Can settle for a 2D sea seen from above, if 3D is too expensive.
• Don't need to simulate the effects that moving fish have on the water (e.g. don't need to simulate the whirlpools that get created behind a fish moving its fin).
• Could even accept not simulating any motion of the water at all, as a last resort.
• I'm willing to use any language and any library to achieve my goal.

What I really need to simulate though, is the movement of the fish: when it moves a fin, it should move due to the push against the water; a fish aligned with its moment should slow down much less than one diagonal/perpendicular; fish should steer when moving if they're curved; and so on and so forth.

##### What I tried

I've tried to play around with LiquidFun for a bit, but couldn't manage to get decent results.

• I modeled the fish (main body + rear fin) as several bodies connected via Revolute Joints.
• I placed them within a bunch of particles in a world with no gravity.
• I programmed each joint i to rotate by sin(time*A + i*B)*C, trying different values for the constants A, B and C.

But nothing worked...

##### What other ideas I have

If no library can give me the behavior I want with real-time performance, I'm thinking that it should be somewhat simple to approximate the movement of the fish in some hacky way without involving fluid dynamics.

I have no idea how to change a fish velocity/acceleration and angularVelocity/torque based on the position and rotation of a fish (main body, rear fin and side fins) and it's current momentum though.

##### Question

Are there any physics libraries (or even just examples or some related physical formula definitions; I'd be happy with anything) which could let me simulate a somewhat physically accurate fish moving in a water?

• Game developers are usually the wrong folks to ask about physical accuracy. We build games to be fun and run fast, which often involves approximations and shortcuts that look plausible or feel good to play with but aren't strictly correct. As an example, when Abzu had to feature believable-looking schools of fish, they just bent the meshes in the vertex shader with some math. If you want advice on physical simulations of articulated bodies, you might want to talk to robotics engineers and folks who work in hydrodynamics. Apr 27, 2023 at 15:06
• You will have to give up at least one of these: quality (physical accuracy in this case), fast execution (e.g. having it run in real time), fast development, or run in on affordable hardware. Apr 28, 2023 at 22:08
• I'm OK with giving up quality. I don't need to simulate the dynamics of the fluid at all (how it reacts to the movement of the fish and behaves over time), but I wish to simulate the mechanics of the fish in as good of a way as possible, so that when part of its body moves, the whole body behaves as if it "pushed" against the water and gets propelled/rotated. May 3, 2023 at 2:30
• Animation sounds like a good way to do that. Have the root motion of the animation drive the movement, and have a swam system pick the animations. May 9, 2023 at 15:27