How it works...

This recipe has a few key elements that make it work:

  • Animated Lift game object: The Lift game object uses animations to go from the up to the down position.
  • Lift as a child game object: The Lift game object is a child of the Elevator game object, which makes it possible to copy the Elevator and use it in multiple places in the scene.
  • Platform.cs script: We are using the same Platform.cs script as in the Animating an object's world position - creating a moving platform recipe. This script parents the character to the Lift. This way the character is forced to move with the Lift, which prevents it from jittering (you can try removing the Platform.cs script from the Lift game object and going down in the Elevator: the character will jump up and down).
  • Player input: We are using player input to set the Move trigger parameter in the Animator Controller of the Elevator. That plays the animation (ElevatorGoingUp or ElevatorGoingDown, depending on the state in which the Elevator is currently in).
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.149.28.126