Links
🐺

MAnimal Controller

The animal script is responsible to control all the Movement logic of the animal. It manages all the Animator and the Rigid Body parameters, and all the States and Modes the animal can do.

Main Principles

Animal Controller(AC) is an animation framework controller, root-motion or In Place, for any creature or HUMANOID character. It uses Rigidbody to interact with the physic world and the Animator to play animations.
AC uses States, Modes, and Stances to play Animations on the animator.

States

States are animations that do not overlap each other. For example, the animal cannot be running and jumping at the same time, or flying and swimming.
These animations also require some internal logic to work.
For walking, the animal requires to be aligned to the ground. For swimming, the animal requires to be aligned to the surface of the water. For Falling, the animal requires gravity to be applied.

Modes

Modes on the other hand are groups of Animations that can be played on top of the State animations. For example, the animal can Attack while running, Dodge while flying, Receive Damage while falling, etc.
In most cases, these animations do not require any specific logic to be applied, but if they need any custom logic: a Mode Modifier can be applied to change some of the effects on the Mode animations.

Stances

Stances are variations of the State animations. For example. The locomotion animations (Walking, Running) can be played in different ways. The character can walk differently if the animal is hurt, or if is crouching/sneaking or standing on 2 legs. He is still on the Locomotion State but in a different stance.

Main Components

The Animal Controller needs an Animator and a RigidBody to work. These two components need to be at the same hierarchy level as the Animal Script.

Animator Component

Since we are using the RigidBody component, the Update Mode is recommended to be set to Animate Physics.

Rigid Body

The RigidBody component allows the animal to interact with other rigid and static objects on the scene.
  • The rotations will be handled by the Animal component so, by code, all the rotations will be frozen:

Colliders

For all creatures, Bipedal or Quadrupeds is recommended to add Colliders on the main bones of the creatures, Like the Spine and the Head. You can however add just one Capsule Collider to the Root GameObject if you like.

Layer

The animal controller by default is set to the Layer "Animal". All the gameobjects in the animal gameobject hierarchy should be set also to the same layer.

Animator Controller

The Animator Controller is the core Animation Logic for the Animal script. It will communicate back and forward with the Animal script to inform which animations are playing and which State, Mode or Stance the is animal at.
For the Animal Controller to work properly, the Animation States are tagged with unique Tags to find and check if the active playing animations match with the ones commanded by the Animal component.
Tags like (Locomotion, Jump, Idle, Fly, Fall, etc).
That way the controller knows if the Animator is playing the right animation on the active State.

On the next pages, you will find what all the Public Parameters on every Group do: