Guides

VRTK_ObjectControl

Overview

Provides a base that all object control locomotions can inherit from.

Script Usage:

This is an abstract class that is to be inherited to a concrete class that provides object control locomotion functionality, therefore this script should not be directly used.

Inspector Parameters

  • Device For Direction: The direction that will be moved in is the direction of this device.
  • Disable Other Controls On Active: If this is checked then whenever the axis on the attached controller is being changed, all other object control scripts of the same type on other controllers will be disabled.
  • Affect On Falling: If a VRTK_BodyPhysics script is present and this is checked, then the object control will affect the play area whilst it is falling.
  • Control Override Object: An optional game object to apply the object control to. If this is blank then the PlayArea will be controlled.
  • Controller: The controller to read the controller events from. If this is blank then it will attempt to get a controller events script from the same GameObject.
  • Body Physics: An optional Body Physics script to check for potential collisions in the moving direction.

Class Variables

  • public enum DirectionDevices - Devices for providing direction.
    • Headset - The headset device.
    • LeftController - The left controller device.
    • RightController - The right controller device.
    • ControlledObject - The controlled object.

Class Events

  • XAxisChanged - Emitted when the X Axis Changes.
  • YAxisChanged - Emitted when the Y Axis Changes.

Unity Events

Adding the VRTK_ObjectControl_UnityEvents component to VRTK_ObjectControl 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

  • GameObject controlledGameObject - The GameObject that is going to be affected.
  • Transform directionDevice - The device that is used for the direction.
  • Vector3 axisDirection - The axis that is being affected.
  • Vector3 axis - The value of the current touchpad touch point based across the axis direction.
  • float deadzone - The value of the deadzone based across the axis direction.
  • bool currentlyFalling - Whether the controlled GameObject is currently falling.
  • bool modifierActive - Whether the modifier button is pressed.