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.unity3d.com/Packages/com.unity.xr.interaction.toolkit@3.1/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 |
---|---|
XRInput |
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 |
---|---|
Interaction |
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 |
---|---|
Interaction |
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 |
---|---|
Motion |
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.
min
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.
min
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 use
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 Mono
Declaration
protected virtual void Awake()
OnDisable()
See Mono
Declaration
protected virtual void OnDisable()
OnEnable()
See Mono
Declaration
protected virtual void OnEnable()
OnValidate()
See Mono
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 |