Tanoda
Leap.Unity.Interaction.AnchorableBehaviour Class Reference

AnchorableBehaviours mix well with InteractionBehaviours you'd like to be able to pick up and place in specific locations, specified by other GameObjects with an Anchor component. More...

Inheritance diagram for Leap.Unity.Interaction.AnchorableBehaviour:

Public Types

enum  EventType {
  OnAttachedToAnchor = 100 , OnLockedToAnchor = 105 , OnDetachedFromAnchor = 110 , WhileAttachedToAnchor = 120 ,
  WhileLockedToAnchor = 125 , OnPostTryAnchorOnGraspEnd = 130
}
 

Public Member Functions

void Detach ()
 Detaches this Anchorable object from its anchor. The anchor reference remains unchanged. Call TryAttach() to re-attach to this object's assigned anchor. More...
 
bool IsValidAnchor (Anchor anchor)
 Returns whether the argument anchor is an acceptable anchor for this anchorable object; that is, whether the argument Anchor is within this behaviour's AnchorGroup if it has one, or if this behaviour has no AnchorGroup, returns true. More...
 
bool IsWithinRange (Anchor anchor)
 Returns whether the specified anchor is within attachment range of this Anchorable object. More...
 
Anchor FindPreferredAnchor ()
 Attempts to find and return the best anchor for this anchorable object to attach to based on its current configuration. If useTrajectory is enabled, the object will consider anchor proximity as well as its own trajectory towards a particular anchor, and may return null if the object is moving away from all of its possible anchors. Otherwise, the object will simply return the nearest valid anchor, or null if there is no valid anchor nearby. More...
 
List< AnchorGetNearbyValidAnchors (bool requireAnchorHasSpace=true, bool requireAnchorActiveAndEnabled=true)
 Returns all anchors within the max anchor range of this anchorable object. If this anchorable object has its anchorGroup property set, only anchors within that AnchorGroup will be returned. By default, this method will only return anchors that have space for an object to attach to it. More...
 
Anchor GetNearestValidAnchor (bool requireWithinRange=true, bool requireAnchorHasSpace=true, bool requireAnchorActiveAndEnabled=true)
 Returns the nearest valid anchor to this Anchorable object. If this anchorable object has its anchorGroup property set, all anchors within that AnchorGroup are valid to be this object's anchor. If there is no valid anchor within range, returns null. By default, this method will only return anchors that are within the max anchor range of this object and that have space for an object to attach to it. More...
 
bool TryAttach (bool ignoreRange=false)
 Attempts to attach to this Anchorable object's currently specified anchor. The attempt may fail if this anchor is out of range. Optionally, the range requirement can be ignored. More...
 
bool TryAttachToNearestAnchor ()
 Attempts to find and attach this anchorable object to the nearest valid anchor, or the most optimal nearby anchor based on proximity and the object's trajectory if useTrajectory is enabled. More...
 

Static Public Member Functions

static float GetAnchorScore (Vector3 anchObjPos, Vector3 anchObjVel, Vector3 anchorPos, float maxDistance, float nonDirectedMaxDistance, float minAngleProduct, float alwaysAttachDistance=0f)
 Calculates and returns a score from 0 (non-valid anchor) to 1 (ideal anchor) based on the argument configuration, using an anchorable object's position and velocity, an anchor position, and distance/angle settings. A score of zero indicates an invalid anchor no matter what; a non-zero score indicates a possible anchor, with more optimal anchors receiving a score closer to 1. More...
 

Public Attributes

float maxAnchorRange = 0.3F
 
bool useTrajectory = true
 
bool lockToAnchor = false
 
bool lockWhenAttached = true
 
bool matchAnchorMotionWhileAttaching = true
 
float anchorLerpCoeffPerSec = 20F
 
bool anchorRotation = false
 
InteractionBehaviour interactionBehaviour
 
bool detachWhenGrasped = true
 
bool isAttractedByHand = false
 
float maxAttractionReach = 0.1F
 
AnimationCurve attractionReachByDistance
 
Action OnAttachedToAnchor = () => { }
 Called when this AnchorableBehaviour attaches to an Anchor. More...
 
Action OnLockedToAnchor = () => { }
 Called when this AnchorableBehaviour locks to an Anchor. More...
 
Action OnDetachedFromAnchor = () => { }
 Called when this AnchorableBehaviour detaches from an Anchor. More...
 
Action WhileAttachedToAnchor = () => { }
 Called during every Update() in which this AnchorableBehaviour is attached to an Anchor. More...
 
Action WhileLockedToAnchor = () => { }
 Called during every Update() in which this AnchorableBehaviour is locked to an Anchor. More...
 
Action OnPostTryAnchorOnGraspEnd = () => { }
 Called just after this anchorable behaviour's InteractionBehaviour OnObjectGraspEnd for this anchor. This callback will never fire if tryAttachAnchorOnGraspEnd is not enabled. More...
 

Properties

bool isAttached [get, set]
 
Anchor anchor [get, set]
 
AnchorGroup anchorGroup [get, set]
 
bool tryAnchorNearestOnGraspEnd [get, set]
 
Anchor preferredAnchor [get]
 Gets the anchor this AnchorableBehaviour would most prefer to attach to. This value is refreshed every Update() during which the AnchorableBehaviour has no anchor or is detached from its current anchor. More...
 

Detailed Description

AnchorableBehaviours mix well with InteractionBehaviours you'd like to be able to pick up and place in specific locations, specified by other GameObjects with an Anchor component.

Definition at line 24 of file AnchorableBehaviour.cs.

Member Enumeration Documentation

◆ EventType

Enumerator
OnAttachedToAnchor 
OnLockedToAnchor 
OnDetachedFromAnchor 
WhileAttachedToAnchor 
WhileLockedToAnchor 
OnPostTryAnchorOnGraspEnd 

Definition at line 816 of file AnchorableBehaviour.cs.

Member Function Documentation

◆ Detach()

void Leap.Unity.Interaction.AnchorableBehaviour.Detach ( )

Detaches this Anchorable object from its anchor. The anchor reference remains unchanged. Call TryAttach() to re-attach to this object's assigned anchor.

Definition at line 383 of file AnchorableBehaviour.cs.

◆ FindPreferredAnchor()

Anchor Leap.Unity.Interaction.AnchorableBehaviour.FindPreferredAnchor ( )

Attempts to find and return the best anchor for this anchorable object to attach to based on its current configuration. If useTrajectory is enabled, the object will consider anchor proximity as well as its own trajectory towards a particular anchor, and may return null if the object is moving away from all of its possible anchors. Otherwise, the object will simply return the nearest valid anchor, or null if there is no valid anchor nearby.

This method is called every Update() automatically by anchorable objects, and its result is stored in preferredAnchor. Only call this if you need a new calculation.

Definition at line 419 of file AnchorableBehaviour.cs.

◆ GetAnchorScore()

static float Leap.Unity.Interaction.AnchorableBehaviour.GetAnchorScore ( Vector3  anchObjPos,
Vector3  anchObjVel,
Vector3  anchorPos,
float  maxDistance,
float  nonDirectedMaxDistance,
float  minAngleProduct,
float  alwaysAttachDistance = 0f 
)
static

Calculates and returns a score from 0 (non-valid anchor) to 1 (ideal anchor) based on the argument configuration, using an anchorable object's position and velocity, an anchor position, and distance/angle settings. A score of zero indicates an invalid anchor no matter what; a non-zero score indicates a possible anchor, with more optimal anchors receiving a score closer to 1.

Definition at line 585 of file AnchorableBehaviour.cs.

◆ GetNearbyValidAnchors()

List< Anchor > Leap.Unity.Interaction.AnchorableBehaviour.GetNearbyValidAnchors ( bool  requireAnchorHasSpace = true,
bool  requireAnchorActiveAndEnabled = true 
)

Returns all anchors within the max anchor range of this anchorable object. If this anchorable object has its anchorGroup property set, only anchors within that AnchorGroup will be returned. By default, this method will only return anchors that have space for an object to attach to it.

Warning: This method checks squared-distance for all anchors in teh scene if this AnchorableBehaviour has no AnchorGroup.

Definition at line 457 of file AnchorableBehaviour.cs.

◆ GetNearestValidAnchor()

Anchor Leap.Unity.Interaction.AnchorableBehaviour.GetNearestValidAnchor ( bool  requireWithinRange = true,
bool  requireAnchorHasSpace = true,
bool  requireAnchorActiveAndEnabled = true 
)

Returns the nearest valid anchor to this Anchorable object. If this anchorable object has its anchorGroup property set, all anchors within that AnchorGroup are valid to be this object's anchor. If there is no valid anchor within range, returns null. By default, this method will only return anchors that are within the max anchor range of this object and that have space for an object to attach to it.

Warning: This method checks squared-distance for all anchors in the scene if this AnchorableBehaviour has no AnchorGroup.

Definition at line 491 of file AnchorableBehaviour.cs.

◆ IsValidAnchor()

bool Leap.Unity.Interaction.AnchorableBehaviour.IsValidAnchor ( Anchor  anchor)

Returns whether the argument anchor is an acceptable anchor for this anchorable object; that is, whether the argument Anchor is within this behaviour's AnchorGroup if it has one, or if this behaviour has no AnchorGroup, returns true.

Definition at line 392 of file AnchorableBehaviour.cs.

◆ IsWithinRange()

bool Leap.Unity.Interaction.AnchorableBehaviour.IsWithinRange ( Anchor  anchor)

Returns whether the specified anchor is within attachment range of this Anchorable object.

Definition at line 404 of file AnchorableBehaviour.cs.

◆ TryAttach()

bool Leap.Unity.Interaction.AnchorableBehaviour.TryAttach ( bool  ignoreRange = false)

Attempts to attach to this Anchorable object's currently specified anchor. The attempt may fail if this anchor is out of range. Optionally, the range requirement can be ignored.

Definition at line 539 of file AnchorableBehaviour.cs.

◆ TryAttachToNearestAnchor()

bool Leap.Unity.Interaction.AnchorableBehaviour.TryAttachToNearestAnchor ( )

Attempts to find and attach this anchorable object to the nearest valid anchor, or the most optimal nearby anchor based on proximity and the object's trajectory if useTrajectory is enabled.

Definition at line 554 of file AnchorableBehaviour.cs.

Member Data Documentation

◆ anchorLerpCoeffPerSec

float Leap.Unity.Interaction.AnchorableBehaviour.anchorLerpCoeffPerSec = 20F

Definition at line 177 of file AnchorableBehaviour.cs.

◆ anchorRotation

bool Leap.Unity.Interaction.AnchorableBehaviour.anchorRotation = false

Definition at line 183 of file AnchorableBehaviour.cs.

◆ attractionReachByDistance

AnimationCurve Leap.Unity.Interaction.AnchorableBehaviour.attractionReachByDistance

Definition at line 229 of file AnchorableBehaviour.cs.

◆ detachWhenGrasped

bool Leap.Unity.Interaction.AnchorableBehaviour.detachWhenGrasped = true

Definition at line 195 of file AnchorableBehaviour.cs.

◆ interactionBehaviour

InteractionBehaviour Leap.Unity.Interaction.AnchorableBehaviour.interactionBehaviour

Definition at line 189 of file AnchorableBehaviour.cs.

◆ isAttractedByHand

bool Leap.Unity.Interaction.AnchorableBehaviour.isAttractedByHand = false

Definition at line 221 of file AnchorableBehaviour.cs.

◆ lockToAnchor

bool Leap.Unity.Interaction.AnchorableBehaviour.lockToAnchor = false

Definition at line 160 of file AnchorableBehaviour.cs.

◆ lockWhenAttached

bool Leap.Unity.Interaction.AnchorableBehaviour.lockWhenAttached = true

Definition at line 166 of file AnchorableBehaviour.cs.

◆ matchAnchorMotionWhileAttaching

bool Leap.Unity.Interaction.AnchorableBehaviour.matchAnchorMotionWhileAttaching = true

Definition at line 172 of file AnchorableBehaviour.cs.

◆ maxAnchorRange

float Leap.Unity.Interaction.AnchorableBehaviour.maxAnchorRange = 0.3F

Definition at line 126 of file AnchorableBehaviour.cs.

◆ maxAttractionReach

float Leap.Unity.Interaction.AnchorableBehaviour.maxAttractionReach = 0.1F

Definition at line 225 of file AnchorableBehaviour.cs.

◆ OnAttachedToAnchor

Action Leap.Unity.Interaction.AnchorableBehaviour.OnAttachedToAnchor = () => { }

Called when this AnchorableBehaviour attaches to an Anchor.

Definition at line 244 of file AnchorableBehaviour.cs.

◆ OnDetachedFromAnchor

Action Leap.Unity.Interaction.AnchorableBehaviour.OnDetachedFromAnchor = () => { }

Called when this AnchorableBehaviour detaches from an Anchor.

Definition at line 254 of file AnchorableBehaviour.cs.

◆ OnLockedToAnchor

Action Leap.Unity.Interaction.AnchorableBehaviour.OnLockedToAnchor = () => { }

Called when this AnchorableBehaviour locks to an Anchor.

Definition at line 249 of file AnchorableBehaviour.cs.

◆ OnPostTryAnchorOnGraspEnd

Action Leap.Unity.Interaction.AnchorableBehaviour.OnPostTryAnchorOnGraspEnd = () => { }

Called just after this anchorable behaviour's InteractionBehaviour OnObjectGraspEnd for this anchor. This callback will never fire if tryAttachAnchorOnGraspEnd is not enabled.

If tryAttachAnchorOnGraspEnd is enabled, the anchor will be attached to an anchor only if its preferredAnchor property is non-null; otherwise, the attempt to anchor failed.

Definition at line 274 of file AnchorableBehaviour.cs.

◆ useTrajectory

bool Leap.Unity.Interaction.AnchorableBehaviour.useTrajectory = true

Definition at line 132 of file AnchorableBehaviour.cs.

◆ WhileAttachedToAnchor

Action Leap.Unity.Interaction.AnchorableBehaviour.WhileAttachedToAnchor = () => { }

Called during every Update() in which this AnchorableBehaviour is attached to an Anchor.

Definition at line 259 of file AnchorableBehaviour.cs.

◆ WhileLockedToAnchor

Action Leap.Unity.Interaction.AnchorableBehaviour.WhileLockedToAnchor = () => { }

Called during every Update() in which this AnchorableBehaviour is locked to an Anchor.

Definition at line 264 of file AnchorableBehaviour.cs.

Property Documentation

◆ anchor

Anchor Leap.Unity.Interaction.AnchorableBehaviour.anchor
getset

Definition at line 72 of file AnchorableBehaviour.cs.

◆ anchorGroup

AnchorGroup Leap.Unity.Interaction.AnchorableBehaviour.anchorGroup
getset

Definition at line 108 of file AnchorableBehaviour.cs.

◆ isAttached

bool Leap.Unity.Interaction.AnchorableBehaviour.isAttached
getset

Definition at line 30 of file AnchorableBehaviour.cs.

◆ preferredAnchor

Anchor Leap.Unity.Interaction.AnchorableBehaviour.preferredAnchor
get

Gets the anchor this AnchorableBehaviour would most prefer to attach to. This value is refreshed every Update() during which the AnchorableBehaviour has no anchor or is detached from its current anchor.

Definition at line 237 of file AnchorableBehaviour.cs.

◆ tryAnchorNearestOnGraspEnd

bool Leap.Unity.Interaction.AnchorableBehaviour.tryAnchorNearestOnGraspEnd
getset

Definition at line 203 of file AnchorableBehaviour.cs.


The documentation for this class was generated from the following file: