Post news RSS Animation Examples and Plans for Improvement

In this post I demonstrate some example animations from the Observatorium prototype and highlight plans for future improvements.

Posted by on


With the gameplay prototype completed, I moved onto a basic art pass with the help of super-talented concept artist Apollo 2D (find him on Indie DB here). The goal of this stage was to lay down a basic ambience for the game whilst exploring the Unity 2D tools in more detail. As part of this pass, we added some basic animations to add depth to the core experience.

Tools

I'm using Unitys built-in Mechanim system for the purpose of managing animation states and controlling the transitions between them. At first I found this system a little tricky to understand so hopefully this post will be of some use to you in your own 2D projects.

Player Animation

The most advanced animation we have in game at present is the rowing animation for the player's avatar which uses the Mechanim system. Here's a first pass of the [forward] rowing animation:

The ship actually has 5 animation states: each of which maps to a specific input - idle (none), rowing (W), rowing reverse (S), rotate left (A) and rotate right (D).

To get my ship game object talking to the animation system I followed the following steps:

Part 1/2 - Editor-side

(1) I attached an Animator component to my ship game object
(2) In the animator window for the associated controller, I dragged in the 5 animation states listed above
(3) I setup transitions between the 5 states - my controls support transitions to and from all states
(4) I added a list of parameters to track when a transition between states should be fired and
(5) I setup conditions for when states should transition between each other using my new parameters

For the sake of this basic pass, I added a handful of boolean parameters to track when a change in state should be fired. E.g. I added a boolean called Rowing which - when set to true - would cause the animation state to go from Idle to Rowing. You can however use any supported variable type here (integer, float, boolean or transition).

Part 2/2 - Code-side

Before I could control animation via a script, I had to create a reference to my Animator. For instance - I added the following code (in C#) to my Awake() function:

animatorReference = artworkReference.GetComponent< Animator >()

Where animatorReference is a variable of type Animator and artworkReference is the game object I attached the Animator component too. Next I had to trigger the desired animation change when an input was detected. For instance, I call the following code when the W key is pressed:

animatorReference.SetBool("Rowing", true);

And that’s pretty much all I needed to do to get the input an animation systems working together.

Mechanim took care of the transitions for me as the 'Rowing' parameter had already been linked with the transition between my 'idle' and 'rowing' states. This is by no means the only way of setting the transitions up but this is how I setup the first pass.

Fish Animation

As you may have read in some of my previous posts, Observatorium is about the synergy between the stars and sealife in each environment: the idea is that the sealife will react positively to changes in the stars and vice-versa. Implementing fish animation behaviour requires a 2 tier approach:

(1) Simple fish

For simple and stationary fish, I'm using basic translation and rotation of game objects. In the example below, the starfish all rotate about their local origin once 'activaed'

Alot of the introductory puzzles use static fish and don't have any complex animation requirements.

(2) Advanced Fish

...however, the ultimate plan for Observatorium is to have a vast range of sealife - some of which will follow complex and curved paths. The orange fish (shown below) are one such example:

At present the orange fish are just being animated using simple translations/rotations. In this particular example, the fish rotate around a central pivot point once activated.

Plans for Improvement

To add more depth to the fish system, I plan to implement some sort of node/spline system so I can make individual fish smoothly traverse any path I choose to setup within the editor. At present I am working on a basic node network that I can use for both the player and the fish. This lets me move fish (and the player) between various points in the world without having to hard code their behaviour; I simply add new nodes to my scene and hit play to have the fish or player object move between them.

Once that process is complete, I will look into gluing the node/spline system onto the animation system so I can trigger bespoke (but reusable) animations at the start or end of the fish movement cycle or when they reach a control point - for instance a transition between idle fish >> moving fish and vice versa.

Stay tuned for additional examples as I develop the animation systems further. If you have any comments or suggestions please post below and I will try to respond.

Thanks for reading!

Clive Lawrence
The Man Who Flew Away

Comments
NicolasLee
NicolasLee

Fantastic. Thanks Clive! Loving these development breakdowns.

Reply Good karma Bad karma+2 votes
TheManWhoFlewAway Author
TheManWhoFlewAway

Thanks Nicolas - glad you're enjoying them :)

Reply Good karma+1 vote
Post a comment
Sign in or join with:

Only registered members can share their thoughts. So come on! Join the community today (totally free - or sign in with your social account on the right) and join in the conversation.