3D animation moves a character's body parts like legs walk, arms swing, head turns. Unlike 2D where you swap sprites, 3D animation uses a rigged model with bones. You need a 3D model that already has animations. Free sources:
- Unity Asset Store: Search "free character" (example: "Kyle" or "Ethan").
- Mixamo (Adobe): Download animated characters for free.
- Sketchfab: Some free animated models etc.
Importing the Model
- Download an FBX file with animations.
- Drag the FBX file into Project window.
- Click the model in Project window - Inspector - Select "Rig" tab.
- Change Animation Type to "Humanoid" (for standard characters).
- Click "Apply" button.
Viewing Available Animations
- Click the model in the Project window.
- Go to the "Animations" tab in Inspector.
You will see a list of animations inside the model:
- Idle
- Walk
- Run
- Jump
Adding Model to Scene
- Drag the model from the Project window into the Scene view
- The character appears in your game world, Select it.
- In Inspector, you will see an Animator component with an Animator Controller already assigned.
Creating an Animator Controller
If the model doesn't have a controller, create one:
- Right-click Project -> Create -> Animator Controller -> Name "CharacterController".
- Open Animator window (Window - Animator).
- Drag the controller onto your character's Animator component.
Adding Animations to Controller
- Open Animator window
- Find animations inside your model (click small arrow next to model in Project - opens sub-items).
- Drag animation clips (Idle, Walk, Run) into Animator window.
Creating Transitions
- Idle - Walk: Right-click Idle -> Make Transition -> Click Walk.
- Walk - Run: Right-click Walk -> Make Transition -> Click Run.
- Reverse transitions: Same steps backward (Run -> Walk, Walk -> Idle).
Adding Parameters
- Animator window -> Parameters tab -> "+" -> Float -> Name "Speed".
Setting Conditions on Transitions
- Idle - Walk transition: Click the arrow -> Inspector -> Condition: Speed > 0.1.
- Walk - Run transition: Condition is Speed > 3.
- Walk - Idle transition: Condition is Speed < 0.1.
- Run - Walk transition: Condition is Speed < 3.
Controlling Animation with Script
Attach this script to your character:
using UnityEngine;
public class CharacterMovement : MonoBehaviour
{
private Animator animator;
private float speed;
void Start()
{
animator = GetComponent<Animator>();
}
void Update()
{
// Get movement input
speed = Input.GetAxis("Vertical");
speed = Mathf.Abs(speed);
// Send to animator
animator.SetFloat("Speed", speed);
// Move character
Vector3 move = transform.forward * speed * 5f * Time.deltaTime;
transform.Translate(move);
}
}
Testing the Animation
Press Play - Use W/S or Up/Down arrow keys:
- No key - Idle.
- Press W a little - Walk.
- Hold Shift while pressing W - Run (if Speed > 3 threshold).