Class XRGrabInteractable
Interactable component that allows basic "grab" functionality. Can attach to a selecting Interactor and follow it around while obeying physics (and inherit velocity when released).
Inherited Members
Namespace: UnityEngine.XR.Interaction.Toolkit
Syntax
public class XRGrabInteractable : XRBaseInteractable
Properties
angularVelocityDamping
Scale factor of how much to dampen the existing angular velocity when tracking the rotation of the Interactor. The smaller the value, the longer it takes for the angular velocity to decay.
Declaration
public float angularVelocityDamping { get; set; }
Property Value
Type | Description |
---|---|
Single |
Remarks
Only applies when in VelocityTracking mode.
See Also
angularVelocityScale
Scale factor applied to the tracked angular velocity while updating the
Declaration
public float angularVelocityScale { get; set; }
Property Value
Type | Description |
---|---|
Single |
Remarks
Only applies when in VelocityTracking mode.
See Also
attachEaseInTime
Time in seconds to ease in the attach when selected (a value of 0 indicates no easing).
Declaration
public float attachEaseInTime { get; set; }
Property Value
Type | Description |
---|---|
Single |
attachPointCompatibilityMode
Controls the method used when calculating the target position of the object. Use Default for consistent attach points between all XRBaseInteractable.MovementType values. Marked for deprecation, this property will be removed in a future version.
Declaration
public XRGrabInteractable.AttachPointCompatibilityMode attachPointCompatibilityMode { get; set; }
Property Value
Type | Description |
---|---|
XRGrabInteractable.AttachPointCompatibilityMode |
Remarks
This is a backwards compatibility option in order to keep the old, incorrect method of calculating the attach point. Projects that already accounted for the difference can use the Legacy option to maintain the same attach positioning from older versions without needing to modify the Attach Transform position.
See Also
attachTransform
The attachment point to use on this Interactable (will use this object's position if none set).
Declaration
public Transform attachTransform { get; set; }
Property Value
Type | Description |
---|---|
Transform |
forceGravityOnDetach
Force this object to have gravity when released (will still use pre-grab value if this is false).
Declaration
public bool forceGravityOnDetach { get; set; }
Property Value
Type | Description |
---|---|
Boolean |
gravityOnDetach
Force this object to have gravity when released (will still use pre-grab value if this is false).
Declaration
public bool gravityOnDetach { get; set; }
Property Value
Type | Description |
---|---|
Boolean |
movementType
Specifies how this object is moved when selected, either through setting the velocity of the
Declaration
public XRBaseInteractable.MovementType movementType { get; set; }
Property Value
Type | Description |
---|---|
XRBaseInteractable.MovementType |
See Also
retainTransformParent
Whether to set the parent of this object back to its original parent this object was a child of after this object is dropped.
Declaration
public bool retainTransformParent { get; set; }
Property Value
Type | Description |
---|---|
Boolean |
smoothPosition
Apply smoothing while following the position of the Interactor when selected.
Declaration
public bool smoothPosition { get; set; }
Property Value
Type | Description |
---|---|
Boolean |
See Also
smoothPositionAmount
Scale factor for how much smoothing is applied while following the position of the Interactor when selected. The larger the value, the closer this object will remain to the position of the Interactor.
Declaration
public float smoothPositionAmount { get; set; }
Property Value
Type | Description |
---|---|
Single |
See Also
smoothRotation
Apply smoothing while following the rotation of the Interactor when selected.
Declaration
public bool smoothRotation { get; set; }
Property Value
Type | Description |
---|---|
Boolean |
See Also
smoothRotationAmount
Scale factor for how much smoothing is applied while following the rotation of the Interactor when selected. The larger the value, the closer this object will remain to the rotation of the Interactor.
Declaration
public float smoothRotationAmount { get; set; }
Property Value
Type | Description |
---|---|
Single |
See Also
throwAngularVelocityScale
Scale factor applied to this object's inherited angular velocity of the Interactor when released.
Declaration
public float throwAngularVelocityScale { get; set; }
Property Value
Type | Description |
---|---|
Single |
See Also
throwOnDetach
Whether this object inherits the velocity of the Interactor when released.
Declaration
public bool throwOnDetach { get; set; }
Property Value
Type | Description |
---|---|
Boolean |
throwSmoothingCurve
The curve to use to weight thrown velocity smoothing (most recent frames to the right).
Declaration
public AnimationCurve throwSmoothingCurve { get; set; }
Property Value
Type | Description |
---|---|
AnimationCurve |
See Also
throwSmoothingDuration
Time period to average thrown velocity over.
Declaration
public float throwSmoothingDuration { get; set; }
Property Value
Type | Description |
---|---|
Single |
See Also
throwVelocityScale
Scale factor applied to this object's inherited velocity of the Interactor when released.
Declaration
public float throwVelocityScale { get; set; }
Property Value
Type | Description |
---|---|
Single |
See Also
tightenPosition
Reduces the maximum follow position difference when using smoothing.
Declaration
public float tightenPosition { get; set; }
Property Value
Type | Description |
---|---|
Single |
Remarks
Fractional amount of how close the smoothed position should remain to the position of the Interactor when using smoothing. The value ranges from 0 meaning no bias in the smoothed follow distance, to 1 meaning effectively no smoothing at all.
See Also
tightenRotation
Reduces the maximum follow rotation difference when using smoothing.
Declaration
public float tightenRotation { get; set; }
Property Value
Type | Description |
---|---|
Single |
Remarks
Fractional amount of how close the smoothed rotation should remain to the rotation of the Interactor when using smoothing. The value ranges from 0 meaning no bias in the smoothed follow rotation, to 1 meaning effectively no smoothing at all.
See Also
trackPosition
Whether this object should follow the position of the Interactor when selected.
Declaration
public bool trackPosition { get; set; }
Property Value
Type | Description |
---|---|
Boolean |
See Also
trackRotation
Whether this object should follow the rotation of the Interactor when selected.
Declaration
public bool trackRotation { get; set; }
Property Value
Type | Description |
---|---|
Boolean |
See Also
velocityDamping
Scale factor of how much to dampen the existing velocity when tracking the position of the Interactor. The smaller the value, the longer it takes for the velocity to decay.
Declaration
public float velocityDamping { get; set; }
Property Value
Type | Description |
---|---|
Single |
Remarks
Only applies when in VelocityTracking mode.
See Also
velocityScale
Scale factor applied to the tracked velocity while updating the
Declaration
public float velocityScale { get; set; }
Property Value
Type | Description |
---|---|
Single |
Remarks
Only applies when in VelocityTracking mode.
See Also
Methods
Awake()
See
Declaration
protected override void Awake()
Overrides
Detach()
Updates the state of the object to finish the detach after being dropped. Automatically called during the end of the frame after being dropped.
Declaration
protected virtual void Detach()
Remarks
This method will update the velocity of the Rigidbody if configured to do so.
See Also
Drop()
Updates the state of the object due to being dropped and schedule to finish the detach during the end of the frame. Automatically called when exiting the Select state.
Declaration
protected virtual void Drop()
See Also
Grab()
Updates the state of the object due to being grabbed. Automatically called when entering the Select state.
Declaration
protected virtual void Grab()
See Also
OnSelectEntering(SelectEnterEventArgs)
This method is called by the Interaction Manager right before the Interactor first initiates selection of an Interactable in a first pass.
Declaration
protected override void OnSelectEntering(SelectEnterEventArgs args)
Parameters
Type | Name | Description |
---|---|---|
SelectEnterEventArgs | args | Event data containing the Interactor that is initiating the selection. |
Overrides
Remarks
args
is only valid during this method call, do not hold a reference to it.
See Also
OnSelectExiting(SelectExitEventArgs)
This method is called by the Interaction Manager right before the Interactor ends selection of an Interactable in a first pass.
Declaration
protected override void OnSelectExiting(SelectExitEventArgs args)
Parameters
Type | Name | Description |
---|---|---|
SelectExitEventArgs | args | Event data containing the Interactor that is ending the selection. |
Overrides
Remarks
args
is only valid during this method call, do not hold a reference to it.
See Also
ProcessInteractable(XRInteractionUpdateOrder.UpdatePhase)
This method is called by the Interaction Manager to update the Interactable. Please see the Interaction Manager documentation for more details on update order.
Declaration
public override void ProcessInteractable(XRInteractionUpdateOrder.UpdatePhase updatePhase)
Parameters
Type | Name | Description |
---|---|---|
XRInteractionUpdateOrder.UpdatePhase | updatePhase | The update phase this is called during. |
Overrides
SetupRigidbodyDrop(Rigidbody)
Setup the
Declaration
protected virtual void SetupRigidbodyDrop(Rigidbody rigidbody)
Parameters
Type | Name | Description |
---|---|---|
Rigidbody | rigidbody | The |
See Also
SetupRigidbodyGrab(Rigidbody)
Setup the
Declaration
protected virtual void SetupRigidbodyGrab(Rigidbody rigidbody)
Parameters
Type | Name | Description |
---|---|---|
Rigidbody | rigidbody | The |