🐺
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.
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 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 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 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.
Since we are using the RigidBody component, the Update Mode is recommended to be set to Animate Physics.

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:

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.
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.

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.

Last modified 8mo ago