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.0/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 |
hasOffset
Indicates whether the anchor currently has an offset applied.
Declaration
public bool hasOffset { get; }
Property Value
Type | Description |
---|---|
bool |
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 |
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 |
momentumDecayScale
Decay scalar for momentum. Higher values will cause momentum to decay faster.
Declaration
public float momentumDecayScale { 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 |
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 |