Tanoda
Leap.Unity.Interaction.InteractionBehaviour Class Reference

InteractionBehaviours are components that enable GameObjects to interact with interaction controllers (InteractionControllerBase) in a physically intuitive way. More...

Inheritance diagram for Leap.Unity.Interaction.InteractionBehaviour:
Leap.Unity.Interaction.IInteractionBehaviour Leap.Unity.Interaction.InteractionButton Leap.Unity.Interaction.InteractionSlider Leap.Unity.Interaction.InteractionToggle

Public Types

enum  GraspedMovementType { Inherit , Kinematic , Nonkinematic }
 
enum  EventType {
  HoverBegin = 100 , HoverEnd = 101 , HoverStay = 102 , PerControllerHoverBegin = 110 ,
  PerControllerHoverEnd = 111 , PrimaryHoverBegin = 120 , PrimaryHoverEnd = 121 , PrimaryHoverStay = 122 ,
  PerControllerPrimaryHoverBegin = 130 , PerControllerPrimaryHoverEnd = 132 , GraspBegin = 140 , GraspEnd = 141 ,
  GraspStay = 142 , PerControllerGraspBegin = 150 , PerControllerGraspEnd = 152 , SuspensionBegin = 160 ,
  SuspensionEnd = 161 , ContactBegin = 170 , ContactEnd = 171 , ContactStay = 172 ,
  PerControllerContactBegin = 180 , PerControllerContactEnd = 181
}
 

Public Member Functions

bool ReleaseFromGrasp ()
 Releases this object from the interaction controller currently grasping it, if it is grasped, and returns true. If the object was not grasped, this method returns false. Directly after calling this method, the object is guaranteed not to be held. However, a grasp may retrigger on the next frame, if the Interaction Controller determines that the released object should be grasped. The safest way to ensure an object is released and ungraspable is to use the interaction object's ignoreGrasp property. More...
 
Vector3 GetGraspPoint (InteractionController intController)
 Returns (approximately) where the argument hand is grasping this object. If the interaction controller is not currently grasping this object, returns Vector3.zero, and logs an error to the Unity console. More...
 
void AddLinearAcceleration (Vector3 acceleration)
 Adds a linear acceleration to the center of mass of this object. Use this instead of Rigidbody.AddForce() to accelerate an Interaction object. More...
 
void AddAngularAcceleration (Vector3 acceleration)
 Adds an angular acceleration to the center of mass of this object. Use this instead of Rigidbody.AddTorque() to add angular acceleration to an Interaction object. More...
 
void SetKinematicWithoutGrasp (bool isKinematic)
 Use this if you want to modify the isKinematic state of an interaction object while it is grasped; otherwise the object's grasp settings may return the Rigidbody to the kinematic state of the object from right before it was grasped. More...
 
bool GetKinematicWithoutGrasp ()
 Use this to retrieve the isKinematic state of the interactino object ignoring any temporary modification to isKinematic that may be due to the object being grasped. More...
 
void FixedUpdateObject ()
 The InteractionManager manually calls method this after all InteractionControllerBase objects are updated via the InteractionManager's FixedUpdate(). More...
 
virtual float GetHoverDistance (Vector3 worldPosition)
 Returns a comparative distance to this interaction object. Calculated by finding the smallest distance to each of the object's colliders. More...
 
void BeginHover (List< InteractionController > controllers)
 
void EndHover (List< InteractionController > controllers)
 
void StayHovered (List< InteractionController > controllers)
 
void ClearHoverTracking (bool onlyInvalidControllers=false)
 Clears hover tracking state for this object on all of the currently-hovering controllers. New hover state will begin anew on the next fixed frame if the appropriate conditions for hover are still fulfilled. More...
 
void BeginPrimaryHover (List< InteractionController > controllers)
 
void EndPrimaryHover (List< InteractionController > controllers)
 
void StayPrimaryHovered (List< InteractionController > controllers)
 
void ClearPrimaryHoverTracking ()
 Clears primary hover tracking state for this object on all of the currently- primary-hovering controllers. New priamry hover state will begin anew on the next fixed frame if the appropriate conditions for primary hover are still fulfilled. More...
 
void BeginContact (List< InteractionController > controllers)
 
void EndContact (List< InteractionController > controllers)
 
void StayContacted (List< InteractionController > controllers)
 
void ClearContactTracking ()
 Clears contact tracking for this object on any currently-contacting controllers. If the object is still contacting controllers and they are appropriately enabled, contact will begin anew on the next fixed frame. More...
 
void BeginGrasp (List< InteractionController > controllers)
 
void EndGrasp (List< InteractionController > controllers)
 
void StayGrasped (List< InteractionController > controllers)
 
void BeginSuspension (InteractionController controller)
 
void EndSuspension (InteractionController controller)
 
void FixedUpdateForces ()
 
void RefreshInteractionColliders ()
 Recursively searches the hierarchy of this Interaction object to find all of the Colliders that are attached to its Rigidbody. These will be the colliders used to calculate distance from the controller to determine which object will become the primary hover. More...
 
void RefreshPositionLockedState ()
 Call this method if the InteractionBehaviour's Rigidbody becomes or unbecomes fully positionally locked (X, Y, Z) or if a Joint attached to the Rigidbody no longer locks its position (e.g. by being destroyed or disabled). More...
 
void FixedUpdateObject ()
 
float GetHoverDistance (Vector3 worldPosition)
 
void BeginHover (List< InteractionController > beganHovering)
 
void EndHover (List< InteractionController > endedHovering)
 
void StayHovered (List< InteractionController > currentlyHovering)
 
void BeginPrimaryHover (List< InteractionController > beganPrimaryHovering)
 
void EndPrimaryHover (List< InteractionController > endedPrimaryHovering)
 
void StayPrimaryHovered (List< InteractionController > currentlyPrimaryHovering)
 
void BeginContact (List< InteractionController > beganContact)
 
void EndContact (List< InteractionController > endedContact)
 
void StayContacted (List< InteractionController > currentlyContacting)
 
void BeginGrasp (List< InteractionController > beganGrasping)
 
void EndGrasp (List< InteractionController > endedGrasping)
 
void StayGrasped (List< InteractionController > currentlyGrasping)
 
void BeginSuspension (InteractionController beganSuspending)
 
void EndSuspension (InteractionController endedSuspending)
 

Public Attributes

Action OnHoverBegin
 Called when the object becomes hovered by any nearby interaction controllers. The hover activity radius is a setting specified by the Interaction Manager. More...
 
Action OnHoverEnd
 Called when the object stops being hovered by any nearby interaction controllers. The hover activity radius is a setting specified by the Interaction Manager. More...
 
Action OnHoverStay
 Called during every fixed (physics) frame in which one or more interaction controller is within the hover activity radius around this object. The hover activity radius is a setting specified by the Interaction Manager. More...
 
Action< InteractionControllerOnPerControllerHoverBegin
 Called whenever an interaction controller enters the hover activity radius around this interaction object. The hover activity radius is a setting specified by the Interaction Manager. More...
 
Action< InteractionControllerOnPerControllerHoverEnd
 Called whenever an interaction controller leaves the hover activity radius around this interaction object. The hover activity radius is a setting specified by the Interaction Manager. More...
 
Action OnPrimaryHoverBegin
 Called when the object becomes primarily hovered by any interaction controllers, if the object was not primarily hovered by any controllers on the previous frame. More...
 
Action OnPrimaryHoverEnd
 Called when the object ceases being the primary hover of any interaction controllers, if the object was primarily hovered by one or more controllers on the previous frame. More...
 
Action OnPrimaryHoverStay
 Called every fixed (physics) frame in which one or more interaction controllers is primarily hovering over this object. Only one object may be the primary hover of a given controller at any one time. More...
 
Action< InteractionControllerOnPerControllerPrimaryHoverBegin
 Called whenever an interaction controller (a Leap hand or supported VR controller) begins primarily hovering over this object. Only one interaction object can be the primary hover of a given controller at a time. More...
 
Action< InteractionControllerOnPerControllerPrimaryHoverEnd
 Called whenever an interaction controler (a Leap hand or supported VR controller) stops primarily hovering over this object. Only one interaction object can be the primary hover of a given controller at a time. More...
 
PoselatestScheduledGraspPose = null
 Nonkinematic grasping motion applies clamped velocities to Interaction Behaviours when they are grasped to move them to their target position and rotation in the grasping hand. If a controller applies its SwapGrasp method to an interaction object that didn't reach its target pose due to velocity clamping, the swapped-out object will inherit the offset as a new target pose relative to the hand. More...
 
GraspedMovementEvent OnGraspedMovement
 Called directly after this grasped object's Rigidbody has had its position and rotation set by its currently grasping controller(s). Subscribe to this callback if you'd like to override the default behaviour for grasping objects, for example, to constrain the object's position or rotation. More...
 
Action OnGraspBegin
 Called when the object becomes grasped, if it was not already held by any interaction controllers on the previous frame. More...
 
Action OnGraspEnd
 Called when the object is no longer grasped by any interaction controllers. More...
 
Action OnGraspStay
 Called every fixed (physics) frame during which this object is grasped by one or more hands. More...
 
Action< InteractionControllerOnPerControllerGraspBegin
 Called whenever an interaction controller grasps this object. More...
 
Action< InteractionControllerOnPerControllerGraspEnd
 Called whenever an interaction controller stops grasping this object. More...
 
Action< InteractionControllerOnSuspensionBegin
 Called when the interaction controller that is grasping this interaction object loses tracking. This can occur if the controller is occluded from the sensor that is tracking it, e.g. by as the user's body or an object in the real world. More...
 
Action< InteractionControllerOnSuspensionEnd
 Called when an object ceases being suspended. An object is suspended if it is currently grasped by an untracked controller. More...
 
Action OnContactBegin
 Called when this object begins colliding with any interaction controllers, if the object was not colliding with any interaction controllers last frame. More...
 
Action OnContactEnd
 Called when the object ceases colliding with any interaction controllers, if the
object was colliding with interaction controllers last frame. More...
 
Action OnContactStay
 Called every frame during which one or more interaction controllers is colliding with this object. More...
 
Action< InteractionControllerOnPerControllerContactBegin
 Called whenever an interaction controller begins colliding with this object. More...
 
Action< InteractionControllerOnPerControllerContactEnd
 Called whenever an interaction controller stops colliding with this object. More...
 
GraspedMovementType graspedMovementType
 

Static Public Attributes

const float MAX_ANGULAR_VELOCITY = 100F
 

Protected Member Functions

virtual void OnValidate ()
 
virtual void Awake ()
 
virtual void OnEnable ()
 
virtual void OnDisable ()
 
virtual void Start ()
 
virtual void fixedUpdateGraspedMovement (Pose origPose, Pose newPose, List< InteractionController > controllers)
 

Protected Attributes

InteractionController _suspendingController = null
 
Vector3 _accumulatedLinearAcceleration = Vector3.zero
 
Vector3 _accumulatedAngularAcceleration = Vector3.zero
 
List< Collider > _interactionColliders = new List<Collider>()
 

Properties

bool isHovered [get]
 Gets whether any interaction controller is nearby. More...
 
InteractionController closestHoveringController [get]
 Gets the closest interaction controller to this object, or null if no controller is nearby. Leap hands and supported VR controllers both count as "controllers" for the purposes of this getter. More...
 
Hand closestHoveringHand [get]
 Gets the closest Leap hand to this object, or null if no hand is nearby. More...
 
float closestHoveringControllerDistance [get]
 Gets the distance from this object to the palm of the closest hand to this object, or float.PositiveInfinity of no hand is nearby. More...
 
ReadonlyHashSet< InteractionControllerhoveringControllers [get]
 Gets all of the interaction controllers hovering near this object, whether they are Leap hands or supported VR controllers. More...
 
bool isPrimaryHovered [get]
 Gets whether this object is the primary hover for any interaction controller. More...
 
InteractionController primaryHoveringController [get]
 Gets the closest primary hovering interaction controller for this object, if it has one. An interaction controller can be a Leap hand or a supported VR controller. Any of these controllers can be the primary hover for this interaction object only if the controller is closer to it than any other interaction object. If there are multiple such controllers, this getter will return the closest one. More...
 
ReadonlyHashSet< InteractionControllerprimaryHoveringControllers [get]
 Gets the set of all interaction controllers primarily hovering over this object. More...
 
Hand primaryHoveringHand [get]
 Gets the primary hovering hand for this interaction object, if it has one. A hand is the primary hover for an interaction object only if it is closer to that object than any other interaction object. If there are multiple such hands, returns the hand closest to this object. More...
 
Finger primaryHoveringFinger [get]
 Gets the finger that is currently primarily hovering over this object, of the closest primarily hovering hand. Will return null if this object is not currently any Leap hand's primary hover. More...
 
Vector3 primaryHoveringControllerPoint [get]
 Gets the position of the primaryHoverPoint on the primary hovering interaction controller that is primarily hovering over this object. For example, if the primarily hovering controller is a Leap hand, this will be the position of the fingertip that is closest to this object. More...
 
float primaryHoverDistance [get]
 Gets the distance to the primary hover point whose controller is primarily hovering over this object. For example, if the primary hovering controller is a Leap hand, this will return the distance to the fingertip that is closest to this object. More...
 
bool isGrasped [get]
 Gets whether this object is grasped by any interaction controller. More...
 
InteractionController graspingController [get]
 Gets the controller currently grasping this object. Warning: If allowMultigrasp is enabled on this object, it might have multiple grasping controllers, in which case this will only return one of the controllers grasping this object, and there is no guarantee on which controller is returned! If no controllers (Leap hands or supported VR controllers) are currently grasping this object, returns null. More...
 
ReadonlyHashSet< InteractionControllergraspingControllers [get]
 Gets the set of all interaction controllers currently grasping this object. Interaction controllers include Leap hands via InteractionHand and supported VR controllers. More...
 
ReadonlyHashSet< InteractionHandgraspingHands [get]
 Gets a set of all Leap hands currently grasping this object. More...
 
bool isSuspended [get]
 Gets whether the object is currently suspended. An object is "suspended" if it is currently grasped by an untracked controller. For more details, refer to OnSuspensionBegin. More...
 
ReadonlyHashSet< InteractionControllercontactingControllers [get]
 Gets a set of all InteractionControllers currently contacting this interaction object. More...
 
InteractionManager manager [get, set]
 
Rigidbody rigidbody [get, protected set]
 The Rigidbody associated with this interaction object. More...
 
ISpaceComponent space [get, protected set]
 
IgnoreHoverMode ignoreHoverMode [get, set]
 
bool ignorePrimaryHover [get, set]
 
bool ignoreContact [get, set]
 
bool ignoreGrasping [get, set]
 
ContactForceMode contactForceMode [get, set]
 
bool allowMultiGrasp [get, set]
 
bool moveObjectWhenGrasped [get, set]
 
bool overrideInteractionLayer [get, set]
 
SingleLayer interactionLayer [get, protected set]
 
bool overrideNoContactLayer [get, set]
 
SingleLayer noContactLayer [get, protected set]
 
List< Collider > primaryHoverColliders [get]
 Gets the List of Colliders used for hover distance checking for this Interaction object. Hover distancing checking will affect which object is chosen for an interaction controller's primary hover, as well as for determining this object's closest hovering controller. More...
 
IGraspedPoseHandler graspedPoseHandler [get, set]
 Gets or sets the grasped pose handler for this Interaction object. More...
 
IThrowHandler throwHandler [get, set]
 Gets or sets the throw handler for this Interaction object. More...
 
bool isPositionLocked [get]
 Returns whether the InteractionBehaviour has its position fully locked by its Rigidbody settings or by any attached PhysX Joints. More...
 
- Properties inherited from Leap.Unity.Interaction.IInteractionBehaviour
string name [get]
 
GameObject gameObject [get]
 
Transform transform [get]
 
InteractionManager manager [get]
 
Rigidbody rigidbody [get]
 
ISpaceComponent space [get]
 
IgnoreHoverMode ignoreHoverMode [get]
 
bool ignorePrimaryHover [get]
 
bool ignoreContact [get]
 
bool ignoreGrasping [get]
 
bool allowMultiGrasp [get]
 
SingleLayer interactionLayer [get]
 
SingleLayer noContactLayer [get]
 
bool isGrasped [get]
 
bool isSuspended [get]
 

Detailed Description

InteractionBehaviours are components that enable GameObjects to interact with interaction controllers (InteractionControllerBase) in a physically intuitive way.

By default, they represent objects that can be poked, prodded, smacked, grasped, and thrown around by Interaction controllers, including Leap hands. They also provide a thorough public API with settings and hovering, contact, and grasping callbacks for creating physical interfaces or overriding the default physical behavior of the object.

In documentation and some method calls, GameObjects with an InteractionBehaviour component may be referred to as interaction objects.

Definition at line 36 of file InteractionBehaviour.cs.

Member Enumeration Documentation

◆ EventType

Enumerator
HoverBegin 
HoverEnd 
HoverStay 
PerControllerHoverBegin 
PerControllerHoverEnd 
PrimaryHoverBegin 
PrimaryHoverEnd 
PrimaryHoverStay 
PerControllerPrimaryHoverBegin 
PerControllerPrimaryHoverEnd 
GraspBegin 
GraspEnd 
GraspStay 
PerControllerGraspBegin 
PerControllerGraspEnd 
SuspensionBegin 
SuspensionEnd 
ContactBegin 
ContactEnd 
ContactStay 
PerControllerContactBegin 
PerControllerContactEnd 

Definition at line 1620 of file InteractionBehaviour.cs.

◆ GraspedMovementType

Enumerator
Inherit 
Kinematic 
Nonkinematic 

Definition at line 715 of file InteractionBehaviour.cs.

Member Function Documentation

◆ AddAngularAcceleration()

void Leap.Unity.Interaction.InteractionBehaviour.AddAngularAcceleration ( Vector3  acceleration)

Adds an angular acceleration to the center of mass of this object. Use this instead of Rigidbody.AddTorque() to add angular acceleration to an Interaction object.

Rigidbody.AddTorque() will work in most scenarios, but will produce unexpected behavior when interaction controllers are embedded inside an object due to soft contact. Calling this method instead solves that problem.

Definition at line 532 of file InteractionBehaviour.cs.

◆ AddLinearAcceleration()

void Leap.Unity.Interaction.InteractionBehaviour.AddLinearAcceleration ( Vector3  acceleration)

Adds a linear acceleration to the center of mass of this object. Use this instead of Rigidbody.AddForce() to accelerate an Interaction object.

Rigidbody.AddForce() will work in most scenarios, but will produce unexpected behavior when interaction controllers are embedded inside an object due to soft contact. Calling this method instead solves that problem.

Definition at line 517 of file InteractionBehaviour.cs.

◆ Awake()

virtual void Leap.Unity.Interaction.InteractionBehaviour.Awake ( )
protectedvirtual

Reimplemented in Leap.Unity.Interaction.InteractionToggle.

Definition at line 792 of file InteractionBehaviour.cs.

◆ BeginContact()

void Leap.Unity.Interaction.InteractionBehaviour.BeginContact ( List< InteractionController controllers)

◆ BeginGrasp()

void Leap.Unity.Interaction.InteractionBehaviour.BeginGrasp ( List< InteractionController controllers)

◆ BeginHover()

void Leap.Unity.Interaction.InteractionBehaviour.BeginHover ( List< InteractionController controllers)

◆ BeginPrimaryHover()

void Leap.Unity.Interaction.InteractionBehaviour.BeginPrimaryHover ( List< InteractionController controllers)

◆ BeginSuspension()

void Leap.Unity.Interaction.InteractionBehaviour.BeginSuspension ( InteractionController  controller)

◆ ClearContactTracking()

void Leap.Unity.Interaction.InteractionBehaviour.ClearContactTracking ( )

Clears contact tracking for this object on any currently-contacting controllers. If the object is still contacting controllers and they are appropriately enabled, contact will begin anew on the next fixed frame.

Definition at line 1168 of file InteractionBehaviour.cs.

◆ ClearHoverTracking()

void Leap.Unity.Interaction.InteractionBehaviour.ClearHoverTracking ( bool  onlyInvalidControllers = false)

Clears hover tracking state for this object on all of the currently-hovering controllers. New hover state will begin anew on the next fixed frame if the appropriate conditions for hover are still fulfilled.

Optionally, only clear hover tracking state for controllers that should be ignoring hover for this interaction object due to its ignoreHoverMode.

Definition at line 1001 of file InteractionBehaviour.cs.

◆ ClearPrimaryHoverTracking()

void Leap.Unity.Interaction.InteractionBehaviour.ClearPrimaryHoverTracking ( )

Clears primary hover tracking state for this object on all of the currently- primary-hovering controllers. New priamry hover state will begin anew on the next fixed frame if the appropriate conditions for primary hover are still fulfilled.

Definition at line 1084 of file InteractionBehaviour.cs.

◆ EndContact()

void Leap.Unity.Interaction.InteractionBehaviour.EndContact ( List< InteractionController controllers)

◆ EndGrasp()

void Leap.Unity.Interaction.InteractionBehaviour.EndGrasp ( List< InteractionController controllers)

◆ EndHover()

void Leap.Unity.Interaction.InteractionBehaviour.EndHover ( List< InteractionController controllers)

◆ EndPrimaryHover()

void Leap.Unity.Interaction.InteractionBehaviour.EndPrimaryHover ( List< InteractionController controllers)

◆ EndSuspension()

void Leap.Unity.Interaction.InteractionBehaviour.EndSuspension ( InteractionController  controller)

◆ FixedUpdateForces()

void Leap.Unity.Interaction.InteractionBehaviour.FixedUpdateForces ( )

Definition at line 1402 of file InteractionBehaviour.cs.

◆ fixedUpdateGraspedMovement()

virtual void Leap.Unity.Interaction.InteractionBehaviour.fixedUpdateGraspedMovement ( Pose  origPose,
Pose  newPose,
List< InteractionController controllers 
)
protectedvirtual

Definition at line 1366 of file InteractionBehaviour.cs.

◆ FixedUpdateObject()

void Leap.Unity.Interaction.InteractionBehaviour.FixedUpdateObject ( )

The InteractionManager manually calls method this after all InteractionControllerBase objects are updated via the InteractionManager's FixedUpdate().

Implements Leap.Unity.Interaction.IInteractionBehaviour.

Definition at line 853 of file InteractionBehaviour.cs.

◆ GetGraspPoint()

Vector3 Leap.Unity.Interaction.InteractionBehaviour.GetGraspPoint ( InteractionController  intController)

Returns (approximately) where the argument hand is grasping this object. If the interaction controller is not currently grasping this object, returns Vector3.zero, and logs an error to the Unity console.

Definition at line 453 of file InteractionBehaviour.cs.

◆ GetHoverDistance()

virtual float Leap.Unity.Interaction.InteractionBehaviour.GetHoverDistance ( Vector3  worldPosition)
virtual

Returns a comparative distance to this interaction object. Calculated by finding the smallest distance to each of the object's colliders.

Any MeshColliders, however, will not have their distances calculated precisely; the squared distance to their bounding box is calculated instead. It is possible to use a custom set of colliders against which to test primary hover calculations: see primaryHoverColliders.

Implements Leap.Unity.Interaction.IInteractionBehaviour.

Definition at line 876 of file InteractionBehaviour.cs.

◆ GetKinematicWithoutGrasp()

bool Leap.Unity.Interaction.InteractionBehaviour.GetKinematicWithoutGrasp ( )

Use this to retrieve the isKinematic state of the interactino object ignoring any temporary modification to isKinematic that may be due to the object being grasped.

Definition at line 557 of file InteractionBehaviour.cs.

◆ OnDisable()

virtual void Leap.Unity.Interaction.InteractionBehaviour.OnDisable ( )
protectedvirtual

◆ OnEnable()

virtual void Leap.Unity.Interaction.InteractionBehaviour.OnEnable ( )
protectedvirtual

◆ OnValidate()

virtual void Leap.Unity.Interaction.InteractionBehaviour.OnValidate ( )
protectedvirtual

Reimplemented in Leap.Unity.Interaction.InteractionSlider.

Definition at line 785 of file InteractionBehaviour.cs.

◆ RefreshInteractionColliders()

void Leap.Unity.Interaction.InteractionBehaviour.RefreshInteractionColliders ( )

Recursively searches the hierarchy of this Interaction object to find all of the Colliders that are attached to its Rigidbody. These will be the colliders used to calculate distance from the controller to determine which object will become the primary hover.

Call this method manually if you change an Interaction object's colliders after its Start() method has been called! (Called automatically in OnEnable.)

Definition at line 1436 of file InteractionBehaviour.cs.

◆ RefreshPositionLockedState()

void Leap.Unity.Interaction.InteractionBehaviour.RefreshPositionLockedState ( )

Call this method if the InteractionBehaviour's Rigidbody becomes or unbecomes fully positionally locked (X, Y, Z) or if a Joint attached to the Rigidbody no longer locks its position (e.g. by being destroyed or disabled).

Definition at line 1566 of file InteractionBehaviour.cs.

◆ ReleaseFromGrasp()

bool Leap.Unity.Interaction.InteractionBehaviour.ReleaseFromGrasp ( )

Releases this object from the interaction controller currently grasping it, if it is grasped, and returns true. If the object was not grasped, this method returns false. Directly after calling this method, the object is guaranteed not to be held. However, a grasp may retrigger on the next frame, if the Interaction Controller determines that the released object should be grasped. The safest way to ensure an object is released and ungraspable is to use the interaction object's ignoreGrasp property.

Definition at line 439 of file InteractionBehaviour.cs.

◆ SetKinematicWithoutGrasp()

void Leap.Unity.Interaction.InteractionBehaviour.SetKinematicWithoutGrasp ( bool  isKinematic)

Use this if you want to modify the isKinematic state of an interaction object while it is grasped; otherwise the object's grasp settings may return the Rigidbody to the kinematic state of the object from right before it was grasped.

Definition at line 545 of file InteractionBehaviour.cs.

◆ Start()

virtual void Leap.Unity.Interaction.InteractionBehaviour.Start ( )
protectedvirtual

◆ StayContacted()

void Leap.Unity.Interaction.InteractionBehaviour.StayContacted ( List< InteractionController controllers)

◆ StayGrasped()

void Leap.Unity.Interaction.InteractionBehaviour.StayGrasped ( List< InteractionController controllers)

◆ StayHovered()

void Leap.Unity.Interaction.InteractionBehaviour.StayHovered ( List< InteractionController controllers)

◆ StayPrimaryHovered()

void Leap.Unity.Interaction.InteractionBehaviour.StayPrimaryHovered ( List< InteractionController controllers)

Member Data Documentation

◆ _accumulatedAngularAcceleration

Vector3 Leap.Unity.Interaction.InteractionBehaviour._accumulatedAngularAcceleration = Vector3.zero
protected

Definition at line 1400 of file InteractionBehaviour.cs.

◆ _accumulatedLinearAcceleration

Vector3 Leap.Unity.Interaction.InteractionBehaviour._accumulatedLinearAcceleration = Vector3.zero
protected

Definition at line 1399 of file InteractionBehaviour.cs.

◆ _interactionColliders

List<Collider> Leap.Unity.Interaction.InteractionBehaviour._interactionColliders = new List<Collider>()
protected

Definition at line 1425 of file InteractionBehaviour.cs.

◆ _suspendingController

InteractionController Leap.Unity.Interaction.InteractionBehaviour._suspendingController = null
protected

Definition at line 1380 of file InteractionBehaviour.cs.

◆ graspedMovementType

GraspedMovementType Leap.Unity.Interaction.InteractionBehaviour.graspedMovementType

Definition at line 727 of file InteractionBehaviour.cs.

◆ latestScheduledGraspPose

Pose? Leap.Unity.Interaction.InteractionBehaviour.latestScheduledGraspPose = null

Nonkinematic grasping motion applies clamped velocities to Interaction Behaviours when they are grasped to move them to their target position and rotation in the grasping hand. If a controller applies its SwapGrasp method to an interaction object that didn't reach its target pose due to velocity clamping, the swapped-out object will inherit the offset as a new target pose relative to the hand.

To prevent slippage in this scenario, we always track the latest scheduled grasp pose for interaction objects here, and use it whenever possible in the SwapGrasp method.

Definition at line 329 of file InteractionBehaviour.cs.

◆ MAX_ANGULAR_VELOCITY

const float Leap.Unity.Interaction.InteractionBehaviour.MAX_ANGULAR_VELOCITY = 100F
static

Definition at line 38 of file InteractionBehaviour.cs.

◆ OnContactBegin

Action Leap.Unity.Interaction.InteractionBehaviour.OnContactBegin

Called when this object begins colliding with any interaction controllers, if the object was not colliding with any interaction controllers last frame.

Definition at line 480 of file InteractionBehaviour.cs.

◆ OnContactEnd

Action Leap.Unity.Interaction.InteractionBehaviour.OnContactEnd

Called when the object ceases colliding with any interaction controllers, if the
object was colliding with interaction controllers last frame.

Definition at line 486 of file InteractionBehaviour.cs.

◆ OnContactStay

Action Leap.Unity.Interaction.InteractionBehaviour.OnContactStay

Called every frame during which one or more interaction controllers is colliding with this object.

Definition at line 492 of file InteractionBehaviour.cs.

◆ OnGraspBegin

Action Leap.Unity.Interaction.InteractionBehaviour.OnGraspBegin

Called when the object becomes grasped, if it was not already held by any interaction controllers on the previous frame.

If this event is fired on a given frame, it will occur after OnGraspEnd and before OnGraspStay.

Definition at line 358 of file InteractionBehaviour.cs.

◆ OnGraspedMovement

GraspedMovementEvent Leap.Unity.Interaction.InteractionBehaviour.OnGraspedMovement
Initial value:
= (preSolvedPos, preSolvedRot,
solvedPos, solvedRot,
ReadonlyHashSet< InteractionController > graspingControllers
Gets the set of all interaction controllers currently grasping this object. Interaction controllers i...

Called directly after this grasped object's Rigidbody has had its position and rotation set by its currently grasping controller(s). Subscribe to this callback if you'd like to override the default behaviour for grasping objects, for example, to constrain the object's position or rotation.

Use InteractionBehaviour.rigidbody.position and InteractionBehaviour.rigidbody.rotation to set the object's position and rotation. Merely setting the object's Transform's position and rotation is not recommended unless you understand the difference.

This method is called after any OnGraspBegin or OnGraspEnd callbacks, but before OnGraspStay. It is also valid to move the Interaction object (via its Rigidbody) in OnGraspStay, although OnGraspStay does not provide pre- and post-solve data in its callback signature.

Definition at line 347 of file InteractionBehaviour.cs.

◆ OnGraspEnd

Action Leap.Unity.Interaction.InteractionBehaviour.OnGraspEnd

Called when the object is no longer grasped by any interaction controllers.

If this event is fired on a given frame, it will occur before OnGraspBegin and OnGraspStay.

Definition at line 366 of file InteractionBehaviour.cs.

◆ OnGraspStay

Action Leap.Unity.Interaction.InteractionBehaviour.OnGraspStay

Called every fixed (physics) frame during which this object is grasped by one or more hands.

Unless allowMultigrasp is set to true, only one hand will ever be grasping an object at any given time.

If this event is fired on a given frame, it will be fired after all other grasping callbacks, including OnGraspedMovement.

Definition at line 378 of file InteractionBehaviour.cs.

◆ OnHoverBegin

Action Leap.Unity.Interaction.InteractionBehaviour.OnHoverBegin

Called when the object becomes hovered by any nearby interaction controllers. The hover activity radius is a setting specified by the Interaction Manager.

If this event is to be fired on a given frame, it will be called before OnHoverStay, OnPerControllerHoverEnd, and OnHoverEnd, and it will be called after OnPerControllerHoverBegin.

Definition at line 176 of file InteractionBehaviour.cs.

◆ OnHoverEnd

Action Leap.Unity.Interaction.InteractionBehaviour.OnHoverEnd

Called when the object stops being hovered by any nearby interaction controllers. The hover activity radius is a setting specified by the Interaction Manager.

If this event is to be fired on a given frame, it will be called before OnPerControllerHoverBegin, OnHoverBegin, and OnHoverStay, and it will be called after OnPerControllerHoverEnd.

Definition at line 186 of file InteractionBehaviour.cs.

◆ OnHoverStay

Action Leap.Unity.Interaction.InteractionBehaviour.OnHoverStay

Called during every fixed (physics) frame in which one or more interaction controller is within the hover activity radius around this object. The hover activity radius is a setting specified by the Interaction Manager.

"Stay" methods are always called after their "Begin" and "End" counterparts.

Definition at line 196 of file InteractionBehaviour.cs.

◆ OnPerControllerContactBegin

Action<InteractionController> Leap.Unity.Interaction.InteractionBehaviour.OnPerControllerContactBegin

Called whenever an interaction controller begins colliding with this object.

Definition at line 497 of file InteractionBehaviour.cs.

◆ OnPerControllerContactEnd

Action<InteractionController> Leap.Unity.Interaction.InteractionBehaviour.OnPerControllerContactEnd

Called whenever an interaction controller stops colliding with this object.

Definition at line 502 of file InteractionBehaviour.cs.

◆ OnPerControllerGraspBegin

Action<InteractionController> Leap.Unity.Interaction.InteractionBehaviour.OnPerControllerGraspBegin

Called whenever an interaction controller grasps this object.

Unless allowMultigrasp is set to true, only one controller will ever be grasping an object at any given time.

If this event is fired on a given frame, it will be called after OnPreControllerGraspEnd and before OnGraspStay.

Definition at line 390 of file InteractionBehaviour.cs.

◆ OnPerControllerGraspEnd

Action<InteractionController> Leap.Unity.Interaction.InteractionBehaviour.OnPerControllerGraspEnd

Called whenever an interaction controller stops grasping this object.

Unless allowMultigrasp is set to true, only one controller will ever be grasping an object at any given time. If a new controller grasps an object while allowMultigrasp is disabled, the object will first receive the end grasp event before receiving the begin grasp event for the newly grasping controller.

If this event is fired on a given frame, it will be before all other grasping callbacks.

Definition at line 402 of file InteractionBehaviour.cs.

◆ OnPerControllerHoverBegin

Action<InteractionController> Leap.Unity.Interaction.InteractionBehaviour.OnPerControllerHoverBegin

Called whenever an interaction controller enters the hover activity radius around this interaction object. The hover activity radius is a setting specified by the Interaction Manager.

If this event is to be fired on a given frame, it will be called after OnPerControllerHandHoverEnd and before OnHoverStay.

Definition at line 206 of file InteractionBehaviour.cs.

◆ OnPerControllerHoverEnd

Action<InteractionController> Leap.Unity.Interaction.InteractionBehaviour.OnPerControllerHoverEnd

Called whenever an interaction controller leaves the hover activity radius around this interaction object. The hover activity radius is a setting specified by the Interaction Manager.

If this event is to be fired on a given frame, it will be called before OnPerControllerHoverBegin and before OnHoverStay.

Definition at line 216 of file InteractionBehaviour.cs.

◆ OnPerControllerPrimaryHoverBegin

Action<InteractionController> Leap.Unity.Interaction.InteractionBehaviour.OnPerControllerPrimaryHoverBegin

Called whenever an interaction controller (a Leap hand or supported VR controller) begins primarily hovering over this object. Only one interaction object can be the primary hover of a given controller at a time.

If this event is to be fired on a given frame, it will be called before OnPrimaryHoverStay, and it will be called after OnPerControllerPrimaryHoverEnd.

Definition at line 261 of file InteractionBehaviour.cs.

◆ OnPerControllerPrimaryHoverEnd

Action<InteractionController> Leap.Unity.Interaction.InteractionBehaviour.OnPerControllerPrimaryHoverEnd

Called whenever an interaction controler (a Leap hand or supported VR controller) stops primarily hovering over this object. Only one interaction object can be the primary hover of a given controller at a time.

If this event is to be fired on a given frame, it will be called before OnPerControllerPrimaryHoverBegin and OnPrimaryHoverStay.

Definition at line 272 of file InteractionBehaviour.cs.

◆ OnPrimaryHoverBegin

Action Leap.Unity.Interaction.InteractionBehaviour.OnPrimaryHoverBegin

Called when the object becomes primarily hovered by any interaction controllers, if the object was not primarily hovered by any controllers on the previous frame.

If this event is fired on a given frame, it will be called before OnPrimaryHoverStay, and it will be called after OnPrimaryHoverEnd.

Definition at line 230 of file InteractionBehaviour.cs.

◆ OnPrimaryHoverEnd

Action Leap.Unity.Interaction.InteractionBehaviour.OnPrimaryHoverEnd

Called when the object ceases being the primary hover of any interaction controllers, if the object was primarily hovered by one or more controllers on the previous frame.

If this event is fired on a given frame, it will be called before OnPrimaryHoverStay and OnPrimaryHoverBegin.

Definition at line 240 of file InteractionBehaviour.cs.

◆ OnPrimaryHoverStay

Action Leap.Unity.Interaction.InteractionBehaviour.OnPrimaryHoverStay

Called every fixed (physics) frame in which one or more interaction controllers is primarily hovering over this object. Only one object may be the primary hover of a given controller at any one time.

"Stay" events are fired after any "End" and "Begin" events have been fired.

Definition at line 250 of file InteractionBehaviour.cs.

◆ OnSuspensionBegin

Action<InteractionController> Leap.Unity.Interaction.InteractionBehaviour.OnSuspensionBegin

Called when the interaction controller that is grasping this interaction object loses tracking. This can occur if the controller is occluded from the sensor that is tracking it, e.g. by as the user's body or an object in the real world.

An object is "suspended" if it is currently grasped by an untracked controller.

By default, suspended objects will hang in the air until the interaction controller grasping them resumes tracking. Subscribe to this callback and OnResume to implement, e.g., the object disappearing and re-appearing.

Definition at line 415 of file InteractionBehaviour.cs.

◆ OnSuspensionEnd

Action<InteractionController> Leap.Unity.Interaction.InteractionBehaviour.OnSuspensionEnd

Called when an object ceases being suspended. An object is suspended if it is currently grasped by an untracked controller.

Grasping a suspended object with a different controller will cease suspension of the object, and will invoke OnSuspensionEnd, although the input to OnSuspensionEnd will be the newly grasping controller, not the controller that suspended the object. OnGraspEnd will also be called for the interaction controller that was formerly causing suspension.

Definition at line 426 of file InteractionBehaviour.cs.

Property Documentation

◆ allowMultiGrasp

bool Leap.Unity.Interaction.InteractionBehaviour.allowMultiGrasp
getset

◆ closestHoveringController

InteractionController Leap.Unity.Interaction.InteractionBehaviour.closestHoveringController
get

Gets the closest interaction controller to this object, or null if no controller is nearby. Leap hands and supported VR controllers both count as "controllers" for the purposes of this getter.

Definition at line 52 of file InteractionBehaviour.cs.

◆ closestHoveringControllerDistance

float Leap.Unity.Interaction.InteractionBehaviour.closestHoveringControllerDistance
get

Gets the distance from this object to the palm of the closest hand to this object, or float.PositiveInfinity of no hand is nearby.

Definition at line 70 of file InteractionBehaviour.cs.

◆ closestHoveringHand

Hand Leap.Unity.Interaction.InteractionBehaviour.closestHoveringHand
get

Gets the closest Leap hand to this object, or null if no hand is nearby.

Definition at line 59 of file InteractionBehaviour.cs.

◆ contactForceMode

ContactForceMode Leap.Unity.Interaction.InteractionBehaviour.contactForceMode
getset

Definition at line 681 of file InteractionBehaviour.cs.

◆ contactingControllers

ReadonlyHashSet<InteractionController> Leap.Unity.Interaction.InteractionBehaviour.contactingControllers
get

Gets a set of all InteractionControllers currently contacting this interaction object.

Definition at line 472 of file InteractionBehaviour.cs.

◆ graspedPoseHandler

IGraspedPoseHandler Leap.Unity.Interaction.InteractionBehaviour.graspedPoseHandler
getset

Gets or sets the grasped pose handler for this Interaction object.

Definition at line 1199 of file InteractionBehaviour.cs.

◆ graspingController

InteractionController Leap.Unity.Interaction.InteractionBehaviour.graspingController
get

Gets the controller currently grasping this object. Warning: If allowMultigrasp is enabled on this object, it might have multiple grasping controllers, in which case this will only return one of the controllers grasping this object, and there is no guarantee on which controller is returned! If no controllers (Leap hands or supported VR controllers) are currently grasping this object, returns null.

Definition at line 290 of file InteractionBehaviour.cs.

◆ graspingControllers

ReadonlyHashSet<InteractionController> Leap.Unity.Interaction.InteractionBehaviour.graspingControllers
get

Gets the set of all interaction controllers currently grasping this object. Interaction controllers include Leap hands via InteractionHand and supported VR controllers.

Definition at line 296 of file InteractionBehaviour.cs.

◆ graspingHands

ReadonlyHashSet<InteractionHand> Leap.Unity.Interaction.InteractionBehaviour.graspingHands
get

Gets a set of all Leap hands currently grasping this object.

Definition at line 302 of file InteractionBehaviour.cs.

◆ hoveringControllers

ReadonlyHashSet<InteractionController> Leap.Unity.Interaction.InteractionBehaviour.hoveringControllers
get

Gets all of the interaction controllers hovering near this object, whether they are Leap hands or supported VR controllers.

Definition at line 80 of file InteractionBehaviour.cs.

◆ ignoreContact

bool Leap.Unity.Interaction.InteractionBehaviour.ignoreContact
getset

◆ ignoreGrasping

bool Leap.Unity.Interaction.InteractionBehaviour.ignoreGrasping
getset

◆ ignoreHoverMode

IgnoreHoverMode Leap.Unity.Interaction.InteractionBehaviour.ignoreHoverMode
getset

◆ ignorePrimaryHover

bool Leap.Unity.Interaction.InteractionBehaviour.ignorePrimaryHover
getset

◆ interactionLayer

SingleLayer Leap.Unity.Interaction.InteractionBehaviour.interactionLayer
getprotected set

◆ isGrasped

bool Leap.Unity.Interaction.InteractionBehaviour.isGrasped
get

Gets whether this object is grasped by any interaction controller.

Implements Leap.Unity.Interaction.IInteractionBehaviour.

Definition at line 281 of file InteractionBehaviour.cs.

◆ isHovered

bool Leap.Unity.Interaction.InteractionBehaviour.isHovered
get

Gets whether any interaction controller is nearby.

Definition at line 45 of file InteractionBehaviour.cs.

◆ isPositionLocked

bool Leap.Unity.Interaction.InteractionBehaviour.isPositionLocked
get

Returns whether the InteractionBehaviour has its position fully locked by its Rigidbody settings or by any attached PhysX Joints.

This is useful for the GraspedMovementController to determine whether it should attempt to move the interaction object or merely rotate it.

If the state of the underlying Rigidbody or Joints changes what this value should be, it will not automatically update (as an optimization) at runtime; instead, manually call RefreshPositionLockedState(). This is because the type-checks required are relatively expensive and mustn't occur every frame.

Definition at line 1559 of file InteractionBehaviour.cs.

◆ isPrimaryHovered

bool Leap.Unity.Interaction.InteractionBehaviour.isPrimaryHovered
get

Gets whether this object is the primary hover for any interaction controller.

Definition at line 89 of file InteractionBehaviour.cs.

◆ isSuspended

bool Leap.Unity.Interaction.InteractionBehaviour.isSuspended
get

Gets whether the object is currently suspended. An object is "suspended" if it is currently grasped by an untracked controller. For more details, refer to OnSuspensionBegin.

Implements Leap.Unity.Interaction.IInteractionBehaviour.

Definition at line 315 of file InteractionBehaviour.cs.

◆ manager

InteractionManager Leap.Unity.Interaction.InteractionBehaviour.manager
getset

◆ moveObjectWhenGrasped

bool Leap.Unity.Interaction.InteractionBehaviour.moveObjectWhenGrasped
getset

Definition at line 703 of file InteractionBehaviour.cs.

◆ noContactLayer

SingleLayer Leap.Unity.Interaction.InteractionBehaviour.noContactLayer
getprotected set

◆ overrideInteractionLayer

bool Leap.Unity.Interaction.InteractionBehaviour.overrideInteractionLayer
getset

Definition at line 737 of file InteractionBehaviour.cs.

◆ overrideNoContactLayer

bool Leap.Unity.Interaction.InteractionBehaviour.overrideNoContactLayer
getset

Definition at line 762 of file InteractionBehaviour.cs.

◆ primaryHoverColliders

List<Collider> Leap.Unity.Interaction.InteractionBehaviour.primaryHoverColliders
get

Gets the List of Colliders used for hover distance checking for this Interaction object. Hover distancing checking will affect which object is chosen for an interaction controller's primary hover, as well as for determining this object's closest hovering controller.

RefreshInteractionColliders() will automatically populate the colliders List with the this rigidbody's colliders, but is only called once on Start(). If you change the colliders for this object at runtime, you should call RefreshInteractionColliders() to keep the _hoverColliders list up-to-date.

If you're feeling brave, you can manually modify this list yourself.

Hover candidacy is determined by a hand-centric PhysX sphere-check against the Interaction object's rigidbody's attached colliders. This behavior cannot be changed, even if you modify the contents of primaryHoverColliders.

However, primary hover is determined by performing distance checks against the colliders in the primaryHoverColliders list, so it IS possible to use different collider(s) for primary hover checks than are used for hover candidacy, by modifying the collider contents of this list. This will also affect which hand is chosen by this object as its closestHoveringHand.

Definition at line 1125 of file InteractionBehaviour.cs.

◆ primaryHoverDistance

float Leap.Unity.Interaction.InteractionBehaviour.primaryHoverDistance
get

Gets the distance to the primary hover point whose controller is primarily hovering over this object. For example, if the primary hovering controller is a Leap hand, this will return the distance to the fingertip that is closest to this object.

If this object is not the primary hover of any interaction controller, returns positive infinity.

Definition at line 159 of file InteractionBehaviour.cs.

◆ primaryHoveringController

InteractionController Leap.Unity.Interaction.InteractionBehaviour.primaryHoveringController
get

Gets the closest primary hovering interaction controller for this object, if it has one. An interaction controller can be a Leap hand or a supported VR controller. Any of these controllers can be the primary hover for this interaction object only if the controller is closer to it than any other interaction object. If there are multiple such controllers, this getter will return the closest one.

Definition at line 98 of file InteractionBehaviour.cs.

◆ primaryHoveringControllerPoint

Vector3 Leap.Unity.Interaction.InteractionBehaviour.primaryHoveringControllerPoint
get

Gets the position of the primaryHoverPoint on the primary hovering interaction controller that is primarily hovering over this object. For example, if the primarily hovering controller is a Leap hand, this will be the position of the fingertip that is closest to this object.

Definition at line 145 of file InteractionBehaviour.cs.

◆ primaryHoveringControllers

ReadonlyHashSet<InteractionController> Leap.Unity.Interaction.InteractionBehaviour.primaryHoveringControllers
get

Gets the set of all interaction controllers primarily hovering over this object.

Definition at line 107 of file InteractionBehaviour.cs.

◆ primaryHoveringFinger

Finger Leap.Unity.Interaction.InteractionBehaviour.primaryHoveringFinger
get

Gets the finger that is currently primarily hovering over this object, of the closest primarily hovering hand. Will return null if this object is not currently any Leap hand's primary hover.

Definition at line 131 of file InteractionBehaviour.cs.

◆ primaryHoveringHand

Hand Leap.Unity.Interaction.InteractionBehaviour.primaryHoveringHand
get

Gets the primary hovering hand for this interaction object, if it has one. A hand is the primary hover for an interaction object only if it is closer to that object than any other interaction object. If there are multiple such hands, returns the hand closest to this object.

Definition at line 119 of file InteractionBehaviour.cs.

◆ rigidbody

Rigidbody Leap.Unity.Interaction.InteractionBehaviour.rigidbody
getprotected set

The Rigidbody associated with this interaction object.

Implements Leap.Unity.Interaction.IInteractionBehaviour.

Definition at line 599 of file InteractionBehaviour.cs.

◆ space

ISpaceComponent Leap.Unity.Interaction.InteractionBehaviour.space
getprotected set

◆ throwHandler

IThrowHandler Leap.Unity.Interaction.InteractionBehaviour.throwHandler
getset

Gets or sets the throw handler for this Interaction object.

Definition at line 1233 of file InteractionBehaviour.cs.


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