Lesson 2

Step A: Set Up Animator

  1. Create pickup trigger
  2. Create open trigger
  3. Add Root|Idle (1) first, then Root|Walk, Root|Interact_standing (1), Root|Interact_ground (1)

Right click and make transitions as shown

Step B: Set Up Transitions:

  • Idle > Walk  No exit time, Condition: isWalking is True 
  • Walk > Idle  No exit time, Condition: isWalking is False 
  • No exit time 
  • Condition: pickup triggered 

  • Has Exit Time
  • Condition: isWalking is false 

  • No exit time 
  • Condition: pickup triggered 

  • Has Exit Time
  • Condition: isWalking is true

 

  • No exit time 
  • Condition: open triggered 

 

  • No exit time 
  • Condition: isWalking is false 

  • No exit time 
  • Condition: open triggered 

 

  • No exit time 
  • Condition: isWalking is true 

 

Step C: Add trigger to the Openable Script:

player.GetComponentInChildren<Animator>().SetTrigger(“open”); 

Openable.cs – Add reference to player’s animator and set “open” trigger, line 41

Step D: Add trigger to the Container Script

Container.cs – Add reference to player’s animator and set “open” trigger, line 46

Step E: Add trigger to the Key Script

player.GetComponentInChildren<Animator>().SetTrigger(“pickup”);

Key.cs – Add reference to player’s animator and set “pickup” trigger, line 43

Don't forget to check out Discover Coding's other fun courses!!