3.8 KiB
Animation Setup Guide (Optional)
This guide explains how to add animations to your unit prefabs. Note: Animations are optional - the units will work perfectly without them!
Why Animations Are Optional
The Unit system is designed to work with or without animations:
- ✅ Without Animator: Units function perfectly (movement, selection, role changes)
- ✅ With Animator: Units get visual feedback for movement, working, attacking, death
Quick Fix for Animation Errors
If you see animation parameter errors in the console, they're harmless but you can eliminate them by:
Option 1: Ignore the Warnings
- The errors don't affect functionality
- Units will work perfectly without animations
- You can continue testing your RTS gameplay
Option 2: Create Simple Animator Controller
-
Create Animator Controller:
- Right-click in Project → Create → Animator Controller
- Name it "UnitAnimatorController"
-
Add Parameters:
- Open the Animator window (Window → Animation → Animator)
- Select your controller
- In Parameters tab, add:
IsMoving(Bool)IsWorking(Bool)Attack(Trigger)Death(Trigger)
-
Create Basic States:
- Right-click in Animator → Create State → Empty
- Name states: "Idle", "Moving", "Working", "Attack", "Death"
- Set "Idle" as default (right-click → Set as Layer Default State)
-
Add Transitions (Optional):
- From "Idle" to "Moving": Condition
IsMoving = true - From "Moving" to "Idle": Condition
IsMoving = false - From "Any State" to "Attack": Condition
Attacktrigger - etc.
- From "Idle" to "Moving": Condition
-
Assign to Prefab:
- Select your unit prefab
- In Animator component, drag your controller to "Controller" field
Advanced Animation Setup
For proper animations, you would need:
1. 3D Model with Animations
- Import a 3D character model with animation clips
- Replace the capsule model with your character
2. Animation Clips
- Idle animation
- Walk/Run animation
- Work animation (hammering, gathering, etc.)
- Attack animation
- Death animation
3. Animator Controller Setup
- Create states for each animation clip
- Set up transitions between states based on parameters
- Configure blend trees for smooth transitions
Simple Test Setup (No 3D Models)
If you want to see animation parameters working without custom models:
-
Enable Animator in Prefab Creator:
- Tools → Create Unit Prefab
- Check "Create Animator Component"
- Create prefab
-
Create Basic Controller:
- Follow "Option 2" above to create animator controller
- You won't see visual changes, but no more errors
-
Test Parameters:
- Watch the Animator window while playing
- Parameters will change as units move and work
Recommended Workflow
For prototyping and testing RTS gameplay:
- ✅ Skip animations initially - focus on gameplay
- ✅ Test unit selection, movement, role changes
- ✅ Add animations later when core gameplay works
For final game:
- ✅ Get character models with animations
- ✅ Set up proper Animator Controllers
- ✅ Polish animation transitions
Troubleshooting
"Parameter does not exist" errors:
- Cause: Unit expects animator parameters that don't exist
- Fix: Either ignore (harmless) or create animator controller with required parameters
Units not moving smoothly:
- Cause: Missing walk animation or poor transitions
- Fix: Add proper walk animation and set up transitions
Animations not playing:
- Cause: Animator Controller not assigned or missing animation clips
- Fix: Assign controller to Animator component and add animation clips
Remember: Your RTS gameplay works perfectly without animations! Add them when you're ready to polish the visual experience.