Guides
Guides

VRTK_ArtificialSlider

extends VRTK_BaseControllable

Overview

A artificially simulated slider.

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.

Script Usage:

  • Create a slider container GameObject and set the GameObject that is to become the slider as a child of the container.
  • Place the VRTK_ArtificialSlider script onto the GameObject that is to become the slider.

The slider GameObject must not be at the root level and needs to have it's Transform position set to 0,0,0. This is the reason for the container GameObject requirement. Any positioning of the slider must be set on the parent GameObject.

Inspector Parameters

  • Maximum Length: The maximum length that the slider can be moved from the origin position across the Operate Axis. A negative value will allow it to move the opposite way.
  • Min Max Threshold: The normalized position the slider can be within the minimum or maximum slider positions before the minimum or maximum positions are considered reached.
  • Resting Position: The position the slider when it is at the default resting point given in a normalized value of 0f (start point) to 1f (end point).
  • Force Resting Position Threshold: The normalized threshold value the slider has to be within the Resting Position before the slider is forced back to the Resting Position if it is not grabbed.
  • Step Value Range: The minimum and the maximum step values for the slider to register along the Operate Axis.
  • Step Size: The increments the slider value will change in between the Step Value Range.
  • Use Step As Value: If this is checked then the value for the slider will be the step value and not the absolute position of the slider Transform.
  • Snap To Step: If this is checked then the slider will snap to the position of the nearest step along the value range.
  • Snap Force: The speed in which the slider will snap to the relevant point along the Operate Axis
  • Tracking Speed: The speed in which to track the grabbed slider to the interacting object.
  • Precision Grab: If this is checked then when the Interact Grab grabs the Interactable Object, it will grab it with precision and pick it up at the particular point on the Interactable Object that the Interact Touch is touching.
  • Detach Distance: The maximum distance the grabbing object is away from the slider before it is automatically released.
  • Release Friction: The amount of friction to the slider Rigidbody when it is released.
  • Only Interact With: A collection of GameObjects that will be used as the valid collisions to determine if the door can be interacted with.

Class Methods

GetValue/0

public override float GetValue()

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

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

GetNormalizedValue/0

public override float GetNormalizedValue()

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

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

SetValue/1

public override void SetValue(float value)

  • Parameters
    • float value - The new position value
  • Returns
    • none

The SetValue method sets the current position value of the slider

GetStepValue/1

public virtual float GetStepValue(float currentValue)

  • Parameters
    • float currentValue - The current position value of the slider to get the Step Value for.
  • Returns
    • float - The current Step Value based on the slider position.

The GetStepValue method returns the current position of the slider based on the step value range.

SetPositionTarget/2

public virtual void SetPositionTarget(float newPositionTarget, float speed)

  • Parameters
    • float newPositionTarget - The new position target value.
    • float speed - The speed to move to the new position target.
  • Returns
    • none

The SetPositionTarget method allows the setting of the Position Target parameter at runtime.

SetPositionTargetWithStepValue/2

public virtual void SetPositionTargetWithStepValue(float givenStepValue, float speed)

  • Parameters
    • float givenStepValue - The step value within the Step Value Range to set the Position Target parameter to.
    • float speed - The speed to move to the new position target.
  • Returns
    • none

The SetPositionTargetWithStepValue sets the Position Target parameter but uses a value within the Step Value Range.

SetRestingPositionWithStepValue/1

public virtual void SetRestingPositionWithStepValue(float givenStepValue)

  • Parameters
    • float givenStepValue - The step value within the Step Value Range to set the Resting Position parameter to.
  • Returns
    • none

The SetRestingPositionWithStepValue sets the Resting Position parameter but uses a value within the Step Value Range.

GetPositionFromStepValue/1

public virtual float GetPositionFromStepValue(float givenStepValue)

  • Parameters
    • float givenStepValue - The step value to check the position for.
  • Returns
    • float - The position the slider would be at based on the given step value.

The GetPositionFromStepValue returns the position the slider would be at based on the given step value.

IsResting/0

public override bool IsResting()

  • Parameters
    • none
  • Returns
    • bool - Returns true if the slider is at the resting position or within the resting position threshold.

The IsResting method returns whether the slider is at the resting position or within the resting position threshold.

GetControlInteractableObject/0

public virtual VRTK_InteractableObject GetControlInteractableObject()

  • Parameters
    • none
  • Returns
    • VRTK_InteractableObject - The Interactable Object associated with the control.

The GetControlInteractableObject method returns the Interactable Object associated with the control.