Class InteractionAttachController
Manages and controls the anchor position for an XR interaction, handling how interactables snap and follow the interactor. It applies velocity-based scaling for anchor movements and supports stabilization options.
Implements
Inherited Members
Namespace: UnityEngine.XR.Interaction.Toolkit.Attachment
Assembly: Unity.XR.Interaction.Toolkit.dll
Syntax
[DisallowMultipleComponent]
[AddComponentMenu("XR/Interactors/Interaction Attach Controller", 22)]
[HelpURL("https://docs.unity.cn/Packages/com.unity.xr.interaction.toolkit@3.2/api/UnityEngine.XR.Interaction.Toolkit.Attachment.InteractionAttachController.html")]
public class InteractionAttachController : MonoBehaviour, IInteractionAttachController
Properties
angleStabilization
Factor for stabilizing angle. This value represents the maximum angle (in degrees) over which angle stabilization will be applied. Larger values increase the range of stabilization, making the effect more pronounced over a greater angle.
Declaration
public float angleStabilization { get; set; }
Property Value
| Type | Description |
|---|---|
| float |
combineManipulationAxes
Whether to allow simultaneous vertical and horizontal rotation or simultaneous translation and horizontal rotation. Disable to allow only one axis of manipulation input at a time based on which axis is most actuated.
Declaration
public bool combineManipulationAxes { get; set; }
Property Value
| Type | Description |
|---|---|
| bool |
enableDebugLines
Enable debug lines for the attach transform offset and velocity vector.
Declaration
public bool enableDebugLines { get; set; }
Property Value
| Type | Description |
|---|---|
| bool |
hasOffset
Indicates whether the anchor currently has an offset applied.
Declaration
public bool hasOffset { get; }
Property Value
| Type | Description |
|---|---|
| bool |
manipulationInput
Input to use for rotating or translating the attach point closer or further away. This effectively rotates or moves the selected grab interactable along the ray.
Declaration
public XRInputValueReader<Vector2> manipulationInput { get; set; }
Property Value
| Type | Description |
|---|---|
| XRInputValueReader<Vector2> |
manipulationRotateReferenceFrame
The optional reference frame to define the rotation axes when the anchor is rotated when using manipulation input. When not set, vertical rotation (pitch) is around the local x-axis and horizontal rotation (yaw) is around the local y-axis of the anchor.
Declaration
public Transform manipulationRotateReferenceFrame { get; set; }
Property Value
| Type | Description |
|---|---|
| Transform |
manipulationRotateSpeed
Speed at which the anchor is rotated when using manipulation input.
Declaration
public float manipulationRotateSpeed { get; set; }
Property Value
| Type | Description |
|---|---|
| float |
See Also
manipulationTranslateSpeed
Speed at which the anchor is translated when using manipulation input.
Declaration
public float manipulationTranslateSpeed { get; set; }
Property Value
| Type | Description |
|---|---|
| float |
See Also
manipulationXAxisMode
Mode for what the x-axis (left/right) of the manipulation input does when controlling the anchor.
Declaration
public InteractionAttachController.ManipulationXAxisMode manipulationXAxisMode { get; set; }
Property Value
| Type | Description |
|---|---|
| InteractionAttachController.ManipulationXAxisMode |
See Also
manipulationYAxisMode
Mode for what the y-axis (up/down) of the manipulation input does when controlling the anchor.
Declaration
public InteractionAttachController.ManipulationYAxisMode manipulationYAxisMode { get; set; }
Property Value
| Type | Description |
|---|---|
| InteractionAttachController.ManipulationYAxisMode |
See Also
maxAdditionalVelocityScalar
Maximum additional velocity scaling factor for movement, interpolated by a quad bezier curve.
Declaration
public float maxAdditionalVelocityScalar { get; set; }
Property Value
| Type | Description |
|---|---|
| float |
See Also
minAdditionalVelocityScalar
Minimum additional velocity scaling factor for movement, interpolated by a quad bezier curve.
Declaration
public float minAdditionalVelocityScalar { get; set; }
Property Value
| Type | Description |
|---|---|
| float |
See Also
momentumDecayScale
Decay scalar for momentum when triggered with push/pull gesture. Higher values will cause momentum to decay faster.
Declaration
public float momentumDecayScale { get; set; }
Property Value
| Type | Description |
|---|---|
| float |
momentumDecayScaleFromInput
Decay scalar for momentum when triggered with manipulation input. Higher values will cause momentum to decay faster.
Declaration
public float momentumDecayScaleFromInput { get; set; }
Property Value
| Type | Description |
|---|---|
| float |
motionStabilizationMode
Gets or sets the stabilization mode for the motion of the anchor. Determines how the anchor's position and rotation are stabilized relative to the followed transform.
Declaration
public MotionStabilizationMode motionStabilizationMode { get; set; }
Property Value
| Type | Description |
|---|---|
| MotionStabilizationMode |
positionStabilization
Factor for stabilizing position. This value represents the maximum distance (in meters) over which position stabilization will be applied. Larger values increase the range of stabilization, making the effect more pronounced over a greater distance.
Declaration
public float positionStabilization { get; set; }
Property Value
| Type | Description |
|---|---|
| float |
pullVelocityBias
Adjusts the object's velocity calculation when moving towards the user. It modifies the distance-based calculation that determines the velocity scalar. minAdditionalVelocityScalar maxAdditionalVelocityScalar
Declaration
public float pullVelocityBias { get; set; }
Property Value
| Type | Description |
|---|---|
| float |
pushVelocityBias
Adjusts the object's velocity calculation when moving away from the user. It modifies the distance-based calculation that determines the velocity scalar. minAdditionalVelocityScalar maxAdditionalVelocityScalar
Declaration
public float pushVelocityBias { get; set; }
Property Value
| Type | Description |
|---|---|
| float |
smoothOffset
If true offset will be smoothed over time in XR Origin space. May present some instability if smoothing is toggled during an interaction.
Declaration
public bool smoothOffset { get; set; }
Property Value
| Type | Description |
|---|---|
| bool |
smoothingSpeed
Smoothing amount for the anchor's position and rotation. Higher values mean more smoothing occurs faster.
Declaration
public float smoothingSpeed { get; set; }
Property Value
| Type | Description |
|---|---|
| float |
transformToFollow
Gets or sets the transform that the anchor should follow.
Declaration
public Transform transformToFollow { get; set; }
Property Value
| Type | Description |
|---|---|
| Transform |
useDistanceBasedVelocityScaling
Whether to use distance-based velocity scaling for anchor movement.
Declaration
public bool useDistanceBasedVelocityScaling { get; set; }
Property Value
| Type | Description |
|---|---|
| bool |
useManipulationInput
Whether to use input-based manipulation for anchor movement.
Declaration
public bool useManipulationInput { get; set; }
Property Value
| Type | Description |
|---|---|
| bool |
useMomentum
Whether momentum is used when useDistanceBasedVelocityScaling is active.
Declaration
public bool useMomentum { get; set; }
Property Value
| Type | Description |
|---|---|
| bool |
zVelocityRampThreshold
Scales anchor velocity from 0 to 1 based on z-velocity's deviation below a threshold. 0 means no scaling.
Declaration
public float zVelocityRampThreshold { get; set; }
Property Value
| Type | Description |
|---|---|
| float |
Methods
Awake()
See MonoBehaviour.
Declaration
protected virtual void Awake()
OnDisable()
See MonoBehaviour.
Declaration
protected virtual void OnDisable()
OnEnable()
See MonoBehaviour.
Declaration
protected virtual void OnEnable()
OnValidate()
See MonoBehaviour.
Declaration
protected virtual void OnValidate()
ResetOffset()
Resets the anchor child's position and rotation to the origin, removing any applied offsets.
Declaration
public void ResetOffset()
Events
attachUpdated
Event callback used to notify when the attach controller has been updated.
Declaration
public event Action attachUpdated
Event Type
| Type | Description |
|---|---|
| Action |