How it works...

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

  • Rigid Body: Our character needs to have a Rigidbody component to be able to enter the trigger. We set the Rigidbody to Is Kinematic when our character grabs the edge of the cliff. It allows us to control the position of the character only with animation. If we wouldn't turn the Rigidbody to Is Kinematic, we would have to deal with collisions with the cliff game object.
  • Trigger: Our GrabTrigger game object catches our character. When the character enters the trigger, we assume it grabs the edge of the cliff.
  • Position and rotation matching: We use the RootTarget empty game object as the target for our character's transform when it grabs the edge. This concept lets us match the animation with the edge of the cliff. We use the Vector3.Lerp() and Quaternion.Lerp() functions to interpolate the position and rotation of our character in time and match it with the RootTarget's position and rotation.
  • Root motion in GrabEdgeClimb animation: We use an animation with root motion to climb the edge of the cliff.
..................Content has been hidden....................

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