Animal Locomotion: Idle, Walk, Run, Jump Animator Controller Unity

Deer Animal Locomotion Unity 6 with Jump

Creating a lifelike animal character requires a blend of precise technical logic and high-quality artistic assets. In this guide, we break down the process of building a functional movement system for a White-Tailed Deer, specifically designed for use in a Forest Ecosystem Simulator or similar nature-focused projects.

Whether you are a beginner or looking to refine your state machine logic, this tutorial provides a foundational “stepping stone.” We start with a basic configuration to help you understand the core mechanics before moving on to more complex, state-of-the-art animal locomotion systems.

The Tools of the Trade

To bring this deer to life, we utilize a powerful suite of Unity 6 tools:

  • Animator Controller: We build a robust state machine with parameters like Speed and isGrounded to handle transitions between Idle, Walk, Run, and Jump states.
  • Cinemachine FreeLook Camera: This ensures the player’s view is dynamic and follows the animal’s movement naturally across the terrain.
  • C# Scripting: We implement a custom controller that syncs the 3D model’s velocity with the animation states for smooth, responsive movement.

Step 1: Setting up the Animator Controller

1) Create the Controller: Right-click in your Project window -> Create > Animator Controller. Name it PlayerAnimator.

2) Add Parameters: Open the Animator window and add these three parameters:

  • Speed (Float)
  • isGrounded (Bool)
  • Jump (Trigger)

3) Create Locomotion (Idle/Walk/Run):

  • Right-click in the grid -> Create State > From New Blend Tree. Name it Locomotion.
  • Double-click the Blend Tree. Set the Parameter to Speed.
  • Add 3 Motion fields:
    • idle (Threshold: 0)
    • walk (Threshold: 1)
    • run (Threshold: 2)

4) Create the Jump States:

  • Drag your jump start, jump fall, and jump end animations into the Animator.
  • Transitions:
    • Locomotion -> jump start: Condition: Jump (Trigger).
    • jump start -> jump fall: (Has Exit Time, no condition).
    • jump fall -> jump end: Condition: isGrounded = true.
    • jump end -> Locomotion: (Has Exit Time).

Step 2: The C# Script

This script uses the Character Controller component. It calculates movement based on your Cinemachine/Main Camera rotation so that “Forward” is always where the camera is looking.

using UnityEngine;

public class PlayerController : MonoBehaviour
{
    public CharacterController controller;
    public Animator animator;
    public Transform cam;

    [Header("Movement Settings")]
    public float walkSpeed = 2f;
    public float runSpeed = 5f;
    public float gravity = -9.81f;
    public float jumpHeight = 1.5f;
    public float turnSmoothTime = 0.1f;
    float turnSmoothVelocity;

    [Header("Physics Check")]
    Vector3 velocity;
    bool isGrounded;

    void Update()
    {
        // 1. Ground Check
        isGrounded = controller.isGrounded;
        if (isGrounded && velocity.y < 0)
        {
            velocity.y = -2f;
        }
        animator.SetBool("isGrounded", isGrounded);

        // 2. Movement Input
        float horizontal = Input.GetAxisRaw("Horizontal");
        float vertical = Input.GetAxisRaw("Vertical");
        Vector3 direction = new Vector3(horizontal, 0f, vertical).normalized;

        if (direction.magnitude >= 0.1f)
        {
            // Calculate rotation based on Camera
            float targetAngle = Mathf.Atan2(direction.x, direction.z) * Mathf.Rad2Deg + cam.eulerAngles.y;
            float angle = Mathf.SmoothDampAngle(transform.eulerAngles.y, targetAngle, ref turnSmoothVelocity, turnSmoothTime);
            transform.rotation = Quaternion.Euler(0f, angle, 0f);

            Vector3 moveDir = Quaternion.Euler(0f, targetAngle, 0f) * Vector3.forward;
            
            // Determine if running
            bool isRunning = Input.GetKey(KeyCode.LeftShift);
            float currentSpeed = isRunning ? runSpeed : walkSpeed;
            
            controller.Move(moveDir.normalized * currentSpeed * Time.deltaTime);

            // Update Animator Speed (0=Idle, 1=Walk, 2=Run)
            float animSpeed = isRunning ? 2f : 1f;
            animator.SetFloat("Speed", animSpeed, 0.1f, Time.deltaTime);
        }
        else
        {
            animator.SetFloat("Speed", 0f, 0.1f, Time.deltaTime);
        }

        // 3. Jumping
        if (Input.GetButtonDown("Jump") && isGrounded)
        {
            velocity.y = Mathf.Sqrt(jumpHeight * -2f * gravity);
            animator.SetTrigger("Jump");
        }

        // 4. Gravity
        velocity.y += gravity * Time.deltaTime;
        controller.Move(velocity * Time.deltaTime);
    }
}

Step 3: Final Setup in Unity

  1. Component Check: Ensure your Player object has a Character Controller component and an Animator component.
  2. Assign References: * Drag the Main Camera (which Cinemachine follows) into the Cam slot of the script.
    • Drag your PlayerAnimator controller into the Animator component.
  3. Cinemachine: Ensure your Cinemachine FreeLook “Follow” and “Look At” targets are set to your player’s transform (or a rig bone).

Pro Tip: In the jump fall animation state in the Animator, make sure “Loop Time” is checked so the character stays in a falling pose if the jump is very high!

Would you like me to help you adjust the Blend Tree for a 2D movement (Strafing) instead of this 3D rotation style?

Step 3: Final Setup in Unity

  1. Component Check: Ensure your Player object has a Character Controller component and an Animator component.
  2. Assign References: * Drag the Main Camera (which Cinemachine follows) into the Cam slot of the script.
    • Drag your PlayerAnimator controller into the Animator component.
  3. Cinemachine: Ensure your Cinemachine FreeLook “Follow” and “Look At” targets are set to your player’s transform (or a rig bone).

Pro Tip: In the jump fall animation state in the Animator, make sure “Loop Time” is checked so the character stays in a falling pose if the jump is very high!

🦌 Free Asset: Animated White-Tailed Deer

I developed this high-fidelity 3D Deer model specifically for use in Unity 6. It includes a full rig and pre-baked animations (Idle, Walk, Run, Jump).

Download on GitHub: 3D-Model-White-Tailed-Deer-Animated License: Creative Commons Attribution 4.0 International

💡 Looking for a simpler setup? If your project doesn’t require jumping, check out my guide on creating the Simplest Animal Locomotion: Idle, Walk, and Run in Unity. This tutorial strips away the complexity of air-states to get your animal moving on the ground instantly.


B) Explaining the Deer Tutorial Logic

This explanation frames your current deer project as a foundational “stepping stone” toward professional-grade game development.

The “Foundation First” Approach: In this specific tutorial, we have developed the animation logic for a White-Tailed Deer. While the configuration we built is considered a “Basic Setup,” it is designed specifically to help you master the core mechanics of Unity’s Animator Controller.

By understanding how these basic states (Idle, Walk, Run, and Jump) interact through parameters like Speed and isGrounded, you are building the mental framework required to create state-of-the-art animal locomotion. Advanced logic—such as procedural gait animation, multi-directional strafing, or dynamic weight shifting—all rely on these same fundamental principles you are learning here.