Guides

VRTK_PlayerClimb

Overview

Provides the ability for the SDK Camera Rig to be moved around based on whether an Interact Grab is interacting with a Climbable Interactable Object to simulate climbing.

Required Components:

  • VRTK_BodyPhysics - A Body Physics script to deal with the effects of physics and gravity on the play area.

Optional Components:

  • VRTK_BasicTeleport - A Teleporter script to use when snapping the play area to the nearest floor when releasing from grab.
  • VRTK_HeadsetCollision - A Headset Collision script to determine when the headset is colliding with geometry to know when to reset to a valid location.
  • VRTK_PositionRewind - A Position Rewind script to utilise when resetting to a valid location upon ungrabbing whilst colliding with geometry.

Script Usage:

  • Place the VRTK_PlayerClimb script on any active scene GameObject.

Script Dependencies:

  • The controller Script Alias GameObject requires the Interact Touch and Interact Grab scripts to allow for touching and grabbing of Interactable Objects.
  • An Interactable Object in the scene that has the Climbable Grab Attach Mechanic.

Inspector Parameters

  • Use Player Scale: Will scale movement up and down based on the player transform's scale.
  • Body Physics: The Body Physics script to use for dealing with climbing and falling. If this is left blank then the script will need to be applied to the same GameObject.
  • Teleporter: The Teleport script to use when snapping to nearest floor on release. If this is left blank then a Teleport script will need to be applied to the same GameObject.
  • Headset Collision: The Headset Collision script to use for determining if the user is climbing inside a collidable object. If this is left blank then the script will need to be applied to the same GameObject.
  • Position Rewind: The Position Rewind script to use for dealing resetting invalid positions. If this is left blank then the script will need to be applied to the same GameObject.

Class Events

  • PlayerClimbStarted - Emitted when player climbing has started.
  • PlayerClimbEnded - Emitted when player climbing has ended.

Unity Events

Adding the VRTK_PlayerClimb_UnityEvents component to VRTK_PlayerClimb object allows access to UnityEvents that will react identically to the Class Events.

  • All C# delegate events are mapped to a Unity Event with the On prefix. e.g. MyEvent -> OnMyEvent.

Event Payload

  • VRTK_ControllerReference controllerReference - The reference to the controller doing the interaction.
  • GameObject target - The GameObject of the interactable object that is being interacted with by the controller.

Class Methods

IsClimbing/0

public virtual bool IsClimbing()

  • Parameters
    • none
  • Returns
    • bool - Returns true if climbing is currently taking place.

The IsClimbing method will return if climbing is currently taking place or not.

Example

VRTK/Examples/037_CameraRig_ClimbingFalling shows how to set up a scene with player climbing. There are many different examples showing how the same system can be used in unique ways.