Guides

VRTK_PhysicsPusher

extends VRTK_BasePhysicsControllable

Overview

A physics based pushable pusher.

Required Components:

  • Collider - A Unity Collider to determine when an interaction has occured. Can be a compound collider set in child GameObjects. Will be automatically added at runtime.
  • Rigidbody - A Unity Rigidbody to allow the GameObject to be affected by the Unity Physics System. Will be automatically added at runtime.

Optional Components:

  • VRTK_ControllerRigidbodyActivator - A Controller Rigidbody Activator to automatically enable the controller rigidbody upon touching the pusher.

Script Usage:

  • Create a pusher container GameObject and set the GameObject that is to become the pusher as a child of the newly created container GameObject.
  • Place the VRTK_PhysicsPusher script onto the GameObject that is to become the pusher.

The Physics Pusher script must not be on a root level GameObject. Any runtime world positioning of the pusher must be set on the parent container GameObject.

Inspector Parameters

  • Pressed Distance: The local space distance along the Operate Axis until the pusher reaches the pressed position.
  • Stay Pressed: If this is checked then the pusher will stay in the pressed position when it reaches the maximum position.
  • Min Max Limit Threshold: The threshold in which the pusher's current normalized position along the Operate Axis has to be within the minimum and maximum limits of the pusher.
  • Resting Position: The normalized position of the pusher between the original position and the pressed position that will be considered as the resting position for the pusher.
  • Resting Position Threshold: The normalized value that the pusher can be from the Resting Position before the pusher is considered to be resting when not being interacted with.
  • Position Target: The normalized position of the pusher between the original position and the pressed position. 0f will set the pusher position to the original position, 1f will set the pusher position to the pressed position.
  • Target Force: The amount of force to apply to push the pusher towards the intended target position.

Class Methods

GetValue/0

public override float GetValue()

  • Parameters
    • none
  • Returns
    • float - The actual position of the pusher.

The GetValue method returns the current position value of the pusher.

GetNormalizedValue/0

public override float GetNormalizedValue()

  • Parameters
    • none
  • Returns
    • float - The normalized position of the pusher.

The GetNormalizedValue method returns the current position value of the pusher normalized between 0f and 1f.

SetValue/1

public override void SetValue(float value)

  • Parameters
    • float value - Not used.
  • Returns
    • none

The SetValue method is not implemented as the pusher resets automatically.

IsResting/0

public override bool IsResting()

  • Parameters
    • none
  • Returns
    • bool - Returns true if the pusher is currently at the resting position.

The IsResting method returns whether the pusher is currently at it's resting position.

GetControlJoint/0

public virtual ConfigurableJoint GetControlJoint()

  • Parameters
    • none
  • Returns
    • ConfigurableJoint - The joint associated with the control.

The GetControlJoint method returns the joint associated with the control.