Lesson 3.3 - Don't Just Stand There
Explore the player’s animations
- Double-click on the Player’s Animation Controller, then explore the different Layers, double-clicking on States to see their animations and Transitions to see their conditions
Make the player start off at a run
- In the Parameters tab, change the Speed_f variable to 1.0
- Right-click on Run_Static > Set as Layer Default State
- Single-click the the Run_Static state and adjust the Speed value in the inspector to match the speed of the background
Set up a jump animation
- In PlayerController.cs, declare a new private Animator playerAnim;
- In Start(), set playerAnim = GetComponent<Animator>();
- In the if-statement for when the player jumps, trigger the jump: playerAnim.SetTrigger(“Jump_trig”);
Adjust the jump animation
- In the Animator window, click on the Running_Jump state, then in the inspector and reduce its Speed value to slow down the animation
- Adjust the player’s mass, jump force, and gravity modifier to get your jump just right
Set up a falling animation
- In the condition that player collides with Obstacle, set the Death bool to true
- In the same if-statement, set the DeathType integer to 1
Keep player from unconscious jumping
- To prevent the player from jumping while unconscious, add && !gameOver to the jump condition