Fish AnimationIt's time to finally get those rigid fish boards animating! I saw
this video about Abzu's fish animation that inspired me to get stuck into it.
So quick demonstration of everything wrong with the previous animation and movement of the fish,
- No fin movement to match velocity/ speed.
- They turn on the spot and change direction instantly.
- Feel very rigid and lack any deformation.
Attempt 1 : Rigged PhysicsI took what seemed like the easiest method first. Rig the fish, use unity's hinge joints to connect the different joints and let springs & motors do the rest. It was fast to implement but not quite right..
The flapping of the fin wasn't right at all, after
some research into how fishes actually move it was clear that simple physics wasn't going to give enough control.
I was also concerned with performance, this was 3 joints, and with around 20 fishes in play at once it seemed unreasonable for something so small.
Attempt 2 : Blend TargetsAs they did in Abzu, it made sense to try out some blend shapes to give control over specific poses. I made 2 morph targets for each fin direction (Unfortunately Unity doesn't support scaling a blend shape out of a 0-100 range
yet)
I decided to also make morphs for the bending/ deformation. I tried to imagine these as how the fish would look if it quickly turned and faced a different direction. These were hard to preview with the rotation but with some iterations I had the following,
This worked nicely but unfortunately, as you can see from the side shot, the fish animation is barely noticeable from the side and had to be exaggerated somewhat to work. I don't entirely have a solution for this but I might look at exaggerating the tail flip a little more.
MovementBefore putting this altogether in the game I wanted to change the way the fishes moved.
Previously I just naively pushed the fish around and had it face its velocity.
I changed this to having the fish always move in a forward direction and focus on how the fish rotates.
I mapped the fishes rotation speed and fin animation speed to the velocity and calculate a 'back angle' for applying to the bend morph.
Chasing the mouse at 3 different speeds.
To get this to work appropriately in game it needed to be controlled by the fishes ai, flocking and avoidance/dodging.
I decided on a priority based system where flocking is disabled in certain situations. It isn't ideal though and you'll see some erratic behavior sometimes as the different systems try to change the direction. However it feels rather natural and some randomness is needed.
Gentle Fish Less Gentle Fish
I'm happy with the result, especially considering it is very easy to adjust and author new poses for any new fishes we have in the future.
Let us know what you think!