Friends, food, and flourishing

MalberS magic: idling

The MalberS animal controller (AC) is my go-to tool for animalation. That’s a word now.

It complicated because:

  • It does a lot! Animation, AI, input…  other stuff.
  • AC handles many types of animal behavior.
  • It works with many animal models, not just MalberS’ own. So, it has to be flexible and configurable.

In fact, if you have just an idle and a walk forward animation, you can make an animal walk, trot, and run in circles. MalberS magic at work.

AC is one of those complex assets where you need to understand its architecture and the reasons behind it, if you’re going to get the most from it. MicroVerse is like that, too.

This post looks at a simple use of AC: randomizing idle animations. Most of the explanation is adapted from a MalberS video.

AC is overkill for that task; it’s not to hard to write a script for it. However, doing the idle thing helped me understand how AC works. There are other posts using that knowledge.

AC's animation manages Unity animation controllers

The AC’s Animal component manages the animation controller of a GameObject. Once it’s set up, we can think about behavior like idling, walking, and running, rather than the animations that implement those things.

Say we want a cute doggo in a game. This corgi is from Red Deer’s low poly dog collection. Red Deer does animals well.


Here’s the structure of the root motion version of the prefab:

Corgi structure

The top GO has an animator with no controller:

Corgi inspector

Arm_Dog is the bones, and the last GO, Corgi, has a skinned mesh renderer.

Let’s add a MalberS Animal component to the AGO:

Animal added

It adds a RigidBody itself. I like it when assets take care of things like that.

The idle task

OK, let’s make sure we understand the task. We have several idle animations for the doggo. We want to play one. When that one finishes, we play another, then another what that one finishes in turn. The next animation to play is chosen randomly from the idle animations.

Say you were going to write your own script 📃 (which I have done in the past). You add a state for each idle animation to an animation controller. You make transitions to each state. The first transition happens when the animation parameter IdleAnim equals 1, the next when it equals 2, and so on. Then you write a C# script that runs when the animations finish playing. It picks a random value for IdleAnim, and sets it.

Your script needs to know two things:

  • How many animations there are
  • There’s an integer parameter called IdleAnim

AC can do the random idle thing, too. It’s part of an AC script. AC has to know the same things as your custom script:

  • How many animations there are
  • There’s an integer parameter called IdleAnim

When you configure AC, you tell it these things, so it can order the animation controller around.

AC expects the animation controller to be set up in a certain way. The way you set it up for your custom script and for AC might not be the same, but they’re close.

AC's animal abstraction​

Let’s look at part of AC’s animal model. Just a small part. I bought MalberS’ low-poly deer, already set up to work with AC. Here’s the GameObject:

Deer GameObject

MalberS supplies several components, for input, stats, AI, and other things. We’re just looking at the Animal component.

One aspect of MalberS’ animal abstraction is its state:

Animal states

States are mutually exclusive. An animal can’t swim and jump at the same time.

One of the states is idle. It has an Id of 0, and the tag Idle. Ids and tags are one way AC connects to the animation controllers you make.

Here’s the deer’s animation controller:

Deer animation controller

Two things to notice. First, on the left, are parameters AC uses to control animations. We’ll need to have them in our Corgi’s animation controller, too (though I think the names can change). AC will use those parameters to control animations.

Second, there are substate machines for each state. A substate machine is a group of related states. They make the top-level state machine cleaner. If you have seven idle animations, putting them in the top-level state machine will give you a messy graph. Group them together, and the top-level state machine will have one node for idle animations, rather than seven.

Idle has a transition to itself. That’s how we get another idle animation to play when the first one is finished. When an animation ends, Idles transitions back to itself, where it selects another value for the parameter choosing the idle animation.

Here’s the idle substate machine for the deer:

Idle substate machine

One of the transitions is highlighted (the blue line). Nothing special about it; it’s just the one I happened to click. Here’s its transition rule:

Transition rule

The transition happens when a variable called Random is 13. A strange value, but anyway. Each of the transitions has a different value in the right-hand field.

OK, let’s work on the corgi, to make something similar.

The corgi's turn

Make a corgi in the game (I used a Red Deer’s root motion corgi prefab), and add the Animal component. You should get animator and rigid body components as well. Add them if they’re not there.

Initial Corgi game object

Make a new animator controller, and assign it to the corgi’s animator. It’ll look like this:


Ruh roh. The parameter list is MT. We’ll need to add the parameters AC needs. Easy peasy! On Animal’s Advanced tab, there’s a button for that:

Create required parameters

Since we want to AC to randomize idle animations, add the optional Random parameter:

Add optional random parameter

Now the corgi’s animation controller has the parameters AC needs:

Parameters added

Now let’s add the idle state to the AC Animal component. Select States, click the + button, and chose Idle from the list.

Adding idle

You get:

Idle added


  • The state’s Id is 0.
  • The state’s tag is Idle.

You’ll need that info later.

Make a substate machine, and a transition to it from Any State:

Made idle substate

You want the transition to Idle to happen for the idle state only. So add conditions to the transition:

Idle conditions

Why 0? That’s the Id of the idle state.

OK, now to add the idle animations. The corgi’s FBX file has three idle animations:

Animations in FBX file

Open the idle substate machine, and drag the first one in. I named the new state Idle 1. Set its tag to Idle.

Idle tag

Make a transition from Idle 1 to exit, and add another one from Entry to Idle 1. Yes, there’ll be two links from entry to Idle 1, but only one of them is an animation transition. Click on the entry-to-Idle 1 transition, and select the animator transition.

Select animation transition

That’s the one we want to mess with.

If you were writing a script yourself, you’d enter Idle 1 when a random value was 1. AC does the same thing, using the Random parameter you added earlier. So add that condition for the transition:

Random is 1

Add states and transitions for the other idle animations. Change the value for Random, going up one each time. Make sure the states have the Idle tag.

Three idle states

Now, remember that when one idle animation is done, we want it to randomly pick another. To do that, go back up to the base layer, and add a transition from the Idle substate machine to itself:

Idle transitions to self

Add the Random behavior to Idle:

Random behavior

Set the range to the number of idle animation substates you added.

Run the game, and the corgi should run idle animations randomly. You should see them running in the animation controller.


In this snapshot, Idle 2 is running.

The corgi's pivot points

I also set the corgi’s pivot points. AC uses them when moving the doggo around, e.g., having it turn to the left. The pivot points may not be required for idling, but I added them anyway, for the movement stuff I’ll do later.

There are three points you need to set:

  • Hips
  • Chest
  • Water

Here’s how I set them on the corgi:

Pivot points

Choose the Animal’s General tab, and you’ll see a pivot points section. Click a dot button on the right, to edit them in the scene.

Editing pivot points

Notice I set the Ys for the hips and chest to be the same. I don’t know if that’s essential.


Yay! Idling for all!

Now to get the corgi to walk around.

Leave a Reply

Your email address will not be published. Required fields are marked *