Unity 3D – Stealth Game – Player Animator Controller

1. Projects> Animator folder> Create> Animator Controller> name it ‘PlayerAnimator’

2. MAIN TOP MENU> Window> Animator

3. Animator> BOTTOM LEFT> Parameters

– Speed -> float (velocità)
– Sneaking -> bool (spiare)
– Dead -> bool (morte)
– Shouting -> bool (urlare)

4. Project> Animations> Humanoid> humanoid_idle (inattivo) (box blu)> Idle (animazione) DRAG AND DROP inside Animator window

5. Hierarchy> char_ethan> Inspector> Animator> Controller DRAG ‘PlayerAnimator’ was created at 1.

6. Play

Idle -> Walk -> Run | Run -> Walk -> Idle

7. Animator> RMB> Create State> From New Blend Tree> Inspector> rename it ‘Locomotion’

8. Animator> LMB Double Click> Blend Tree (notare che il layer attuale è Base Layer> Locomotion)

> Inspector, rename it ‘Locomotion’

> Inspector> + Add Motion Field> little circle icon> Walk

> Inspector> + Add Motion Field> little circle icon> Run

> Inspector> Automate Threshold uncheck (soglia automatica)

> Inspector> Compute Threshold> Speed

9. Animator>

> Base Layer (torno al livello base)> ‘Idle’ RMB> Make Transition> DRAG over ‘Locomotion’

> LMB over the Transition Line to select it> Inspector>

>Conditions> Speed> Greater> 0.1

>Conditions> +> Sneaking> false

10. Animator>

> Base Layer (torno al livello base)> ‘Locomotion’ RMB> Make Transition> DRAG over ‘Idle’

> LMB over the Transition Line to select it> Inspector>

>Conditions> Speed> Less> 0.1

Any State -> Die

Create a Transition from ‘Any State’ -> ‘Dying’

Conditions> Dead> true

NOTA BENE:
‘Any State’ significa che si può arrivare alla morte da qualsiasi stato, senza dover creare transizioni complicate dagli altri stati.

Avatar Mask

The Avatar Mask is an additional layer of animation.

1. Project> Animations folder> Create> Avatar Mask, name it ‘PlayerShoutingMask’> Inspector> Humanoid> deselect (they will turn red) the body parts you do not want modify with the Avatar Mask.