Files
RaidersRPG/Assets/Scripts/Animation_Setup_Guide.md
SHOUTING_PIRATE 3d2d2dc3e3 Initial commit
2025-07-01 21:03:21 +01:00

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

  1. Create Animator Controller:

    • Right-click in Project → Create → Animator Controller
    • Name it "UnitAnimatorController"
  2. Add Parameters:

    • Open the Animator window (Window → Animation → Animator)
    • Select your controller
    • In Parameters tab, add:
      • IsMoving (Bool)
      • IsWorking (Bool)
      • Attack (Trigger)
      • Death (Trigger)
  3. 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)
  4. Add Transitions (Optional):

    • From "Idle" to "Moving": Condition IsMoving = true
    • From "Moving" to "Idle": Condition IsMoving = false
    • From "Any State" to "Attack": Condition Attack trigger
    • etc.
  5. 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:

  1. Enable Animator in Prefab Creator:

    • Tools → Create Unit Prefab
    • Check "Create Animator Component"
    • Create prefab
  2. Create Basic Controller:

    • Follow "Option 2" above to create animator controller
    • You won't see visual changes, but no more errors
  3. Test Parameters:

    • Watch the Animator window while playing
    • Parameters will change as units move and work

For prototyping and testing RTS gameplay:

  1. Skip animations initially - focus on gameplay
  2. Test unit selection, movement, role changes
  3. Add animations later when core gameplay works

For final game:

  1. Get character models with animations
  2. Set up proper Animator Controllers
  3. 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.