15using System.Collections.Generic;
35 [RequireComponent(typeof(Rigidbody))]
45 public bool isHovered {
get {
return _hoveringControllers.Count > 0; } }
54 return _closestHoveringController;
61 return _closestHoveringHand ==
null ? null
72 return _closestHoveringControllerDistance;
82 return _hoveringControllers;
100 return _closestPrimaryHoveringController;
109 return _primaryHoveringControllers;
121 return _closestPrimaryHoveringHand ==
null ? null
122 : _closestPrimaryHoveringHand.
leapHand;
134 return _closestPrimaryHoveringHand.
leapHand
220 #region Primary Hover Events
281 public bool isGrasped {
get {
return _graspingControllers.Count > 0; } }
298 private HashSet<InteractionHand> _graspingHandsBuffer =
new HashSet<InteractionHand>();
304 _graspingHandsBuffer.Clear();
305 _graspingControllers.Query().OfType<
InteractionHand>().FillHashSet(_graspingHandsBuffer);
306 return _graspingHandsBuffer;
348 solvedPos, solvedRot,
458 Debug.LogError(
"Cannot get this object's grasp point: It is not currently grasped "
459 +
"by the provided interaction controller.", intController);
473 get {
return _contactingControllers; }
518 _appliedForces =
true;
533 _appliedForces =
true;
547 _wasKinematicBeforeGrasp = isKinematic;
550 _rigidbody.isKinematic = isKinematic;
559 return _wasKinematicBeforeGrasp;
562 return _rigidbody.isKinematic;
572 [Tooltip(
"The Interaction Manager responsible for this interaction object.")]
576 get {
return _manager; }
578 if (Application.isPlaying) {
586 if (Application.isPlaying) {
594 private Rigidbody _rigidbody;
600 get {
return _rigidbody; }
601 protected set { _rigidbody = value; }
606 [Header(
"Interaction Overrides")]
608 [Tooltip(
"This object will not receive callbacks from left controllers, right "
609 +
"controllers, or either hand if this mode is set to anything other than "
614 get {
return _ignoreHoverMode; }
616 _ignoreHoverMode = value;
623 [SerializeField, HideInInspector]
624 private bool _isIgnoringAllHoverState =
false;
626 [Tooltip(
"Interaction controllers will not be able to mark this object as their "
627 +
"primary hover if this property is checked. Primary hover requires hovering "
628 +
"enabled to function, but it can be disabled independently of hovering.")]
630 [
DisableIf(
"_isIgnoringAllHoverState", isEqualTo:
true)]
631 private bool _ignorePrimaryHover =
false;
633 get {
return _ignorePrimaryHover; }
635 _ignorePrimaryHover = value;
637 if (_ignorePrimaryHover) {
643 [Tooltip(
"Interaction controllers will not be able to touch this object if this "
644 +
"property is checked.")]
646 private bool _ignoreContact =
false;
648 get {
return _ignoreContact; }
650 _ignoreContact = value;
652 if (_ignoreContact) {
658 [Tooltip(
"Interaction controllers will not be able to grasp this object if this "
659 +
"property is checked.")]
661 private bool _ignoreGrasping =
false;
663 get {
return _ignoreGrasping; }
665 _ignoreGrasping = value;
673 [Header(
"Contact Settings")]
675 [Tooltip(
"Determines how much force an interaction controller should apply to this "
676 +
"object. For interface-style objects like buttons and sliders, choose UI. "
677 +
"This will make the objects to feel lighter and more reactive to gentle "
678 +
"touches; for normal physical objects, you'll almost always want Object.")]
682 get {
return _contactForceMode; }
683 set { _contactForceMode = value; }
686 [Header(
"Grasp Settings")]
688 [Tooltip(
"Can this object be grasped simultaneously with two or more interaction "
691 private bool _allowMultiGrasp =
false;
693 get {
return _allowMultiGrasp; }
694 set { _allowMultiGrasp = value; }
697 [Tooltip(
"Should interaction controllers move this object when it is grasped? "
698 +
"Without this property checked, objects will still receive grasp callbacks, "
699 +
"but you will need to move them manually via script.")]
701 [OnEditorChange(
"moveObjectWhenGrasped")]
702 private bool _moveObjectWhenGrasped =
true;
704 get {
return _moveObjectWhenGrasped; }
706 if (_moveObjectWhenGrasped != value && value ==
false) {
711 _moveObjectWhenGrasped = value;
720 [Tooltip(
"When the object is held by an interaction controller, how should it move to "
721 +
"its new position? Nonkinematic bodies will collide with other Rigidbodies, "
722 +
"so they might not reach the target position. Kinematic rigidbodies will "
723 +
"always move to the target position, ignoring collisions. Inherit will "
724 +
"simply use the isKinematic state of the Rigidbody from before it was "
726 [
DisableIf(
"_moveObjectWhenGrasped", isEqualTo:
false)]
729 [Header(
"Layer Overrides")]
732 [OnEditorChange(
"overrideInteractionLayer")]
733 [Tooltip(
"If set to true, this interaction object will override the Interaction "
734 +
"Manager's layer setting for its default layer. The interaction layer is "
735 +
"used for an object when it is not grasped and not ignoring contact.")]
736 private bool _overrideInteractionLayer =
false;
739 return _overrideInteractionLayer;
742 _overrideInteractionLayer = value;
746 [Tooltip(
"Sets the override layer to use for this object when it is not grasped and "
747 +
"not ignoring contact.")]
751 get {
return _interactionLayer; }
752 protected set { _interactionLayer = value; }
756 [OnEditorChange(
"overrideNoContactLayer")]
757 [Tooltip(
"If set to true, this interaction object will override the Interaction "
758 +
"Manager's layer setting for its default no-contact layer. The no-contact "
759 +
"layer should not collide with the contact bone layer; it is used when the "
760 +
"interaction object is grasped or when it is ignoring contact.")]
761 private bool _overrideNoContactLayer =
false;
764 return _overrideNoContactLayer;
767 _overrideNoContactLayer = value;
771 [Tooltip(
"Overrides the layer this interaction object should be on when it is grasped "
772 +
"or ignoring contact. This layer should not collide with the contact bone "
773 +
"layer -- the layer interaction controllers' colliders are on.")]
777 get {
return _noContactLayer; }
778 protected set { _noContactLayer = value; }
783 #region Unity Callbacks
789 if (_isIgnoringAllHoverState) _ignorePrimaryHover =
true;
804 Debug.LogError(
"Interaction Behaviours require an Interaction Manager. Please "
805 +
"ensure you have an InteractionManager in your scene.");
806 this.enabled =
false;
820 var leapSpace = collider.transform.GetComponentInParent<
ISpaceComponent>();
821 if (leapSpace !=
null) {
861 private HashSet<InteractionController> _hoveringControllers =
new HashSet<InteractionController>();
864 private float _closestHoveringControllerDistance =
float.PositiveInfinity;
877 float closestComparativeColliderDistance =
float.PositiveInfinity;
878 bool hasColliders =
false;
879 float testDistance =
float.PositiveInfinity;
884 return float.PositiveInfinity;
888 if (!hasColliders) hasColliders =
true;
890 if (collider is MeshCollider) {
893 testDistance = (
Physics.ClosestPoint(worldPosition,
895 collider.attachedRigidbody.position,
896 collider.attachedRigidbody.rotation)
897 - worldPosition).magnitude;
903 testDistance = (collider.transform.TransformPoint(
904 collider.ClosestPointOnSurface(
905 collider.transform.InverseTransformPoint(worldPosition)))
906 - worldPosition).magnitude;
909 if (testDistance < closestComparativeColliderDistance) {
910 closestComparativeColliderDistance = testDistance;
915 return (this.
rigidbody.position - worldPosition).magnitude;
918 return closestComparativeColliderDistance;
922 public void BeginHover(List<InteractionController> controllers) {
923 foreach (var controller
in controllers) {
924 _hoveringControllers.Add(controller);
927 refreshClosestHoveringController();
929 foreach (var controller
in controllers) {
933 if (_hoveringControllers.Count == controllers.Count) {
938 public void EndHover(List<InteractionController> controllers) {
939 foreach (var controller
in controllers) {
940 _hoveringControllers.Remove(controller);
943 refreshClosestHoveringController();
945 foreach (var controller
in controllers) {
949 if (_hoveringControllers.Count == 0) {
954 public void StayHovered(List<InteractionController> controllers) {
955 refreshClosestHoveringController();
959 private void refreshClosestHoveringController() {
960 float closestControllerDistance =
float.PositiveInfinity;
961 _closestHoveringController = getClosestController(_hoveringControllers,
962 out closestControllerDistance);
963 _closestHoveringControllerDistance = closestControllerDistance;
965 float closestHandDistance =
float.PositiveInfinity;
966 _closestHoveringHand = getClosestController(_hoveringControllers,
967 out closestHandDistance,
968 controller => controller.intHand !=
null)
974 out
float closestDistance,
977 float closestHoveringControllerDist =
float.PositiveInfinity;
978 foreach (var controller
in controllers) {
979 if (filter !=
null && filter(controller) ==
false)
continue;
983 || distance < closestHoveringControllerDist) {
985 closestHoveringControllerDist = distance;
989 closestDistance = closestHoveringControllerDist;
1002 var tempControllers = Pool<HashSet<InteractionController>>.Spawn();
1005 if (onlyInvalidControllers && this.ShouldIgnoreHover(controller)) {
1006 tempControllers.Add(controller);
1010 foreach (var controller
in tempControllers) {
1011 controller.ClearHoverTrackingForObject(
this);
1015 tempControllers.Clear();
1016 Pool<HashSet<InteractionController>>.Recycle(tempControllers);
1020 private HashSet<InteractionController> _primaryHoveringControllers =
new HashSet<InteractionController>();
1025 foreach (var controller
in controllers) {
1026 _primaryHoveringControllers.Add(controller);
1029 refreshClosestPrimaryHoveringController();
1031 foreach (var controller
in controllers) {
1035 if (_primaryHoveringControllers.Count == controllers.Count) {
1041 foreach (var controller
in controllers) {
1042 _primaryHoveringControllers.Remove(controller);
1045 refreshClosestPrimaryHoveringController();
1047 foreach (var controller
in controllers) {
1051 if (_primaryHoveringControllers.Count == 0) {
1057 refreshClosestPrimaryHoveringController();
1061 private void refreshClosestPrimaryHoveringController() {
1062 _closestPrimaryHoveringController = getClosestPrimaryHoveringController();
1063 _closestPrimaryHoveringHand = getClosestPrimaryHoveringController((controller) => controller.intHand !=
null) as
InteractionHand;
1068 float closestDist =
float.PositiveInfinity;
1069 foreach (var controller
in _primaryHoveringControllers) {
1070 if (filter !=
null && filter(controller) ==
false)
continue;
1072 if (closestController ==
null || controller.primaryHoverDistance < closestDist) {
1073 closestController = controller;
1077 return closestController;
1085 var tempControllers = Pool<HashSet<InteractionController>>.Spawn();
1088 tempControllers.Add(controller);
1091 foreach (var controller
in tempControllers) {
1092 controller.ClearPrimaryHoverTracking();
1096 tempControllers.Clear();
1097 Pool<HashSet<InteractionController>>.Recycle(tempControllers);
1133 private HashSet<InteractionController> _contactingControllers =
new HashSet<InteractionController>();
1136 foreach (var controller
in controllers) {
1137 _contactingControllers.Add(controller);
1142 if (_contactingControllers.Count == controllers.Count) {
1147 public void EndContact(List<InteractionController> controllers) {
1148 foreach (var controller
in controllers) {
1149 _contactingControllers.Remove(controller);
1154 if (_contactingControllers.Count == 0) {
1169 var tempControllers = Pool<HashSet<InteractionController>>.Spawn();
1172 tempControllers.Add(controller);
1175 foreach (var controller
in tempControllers) {
1176 controller.ClearContactTrackingForObject(
this);
1180 tempControllers.Clear();
1181 Pool<HashSet<InteractionController>>.Recycle(tempControllers);
1189 private HashSet<InteractionController> _graspingControllers =
new HashSet<InteractionController>();
1191 private bool _wasKinematicBeforeGrasp;
1192 private bool _justGrasped =
false;
1194 private float _dragBeforeGrasp = 0F;
1195 private float _angularDragBeforeGrasp = 0.05F;
1201 if (_graspedPoseHandler ==
null) {
1204 return _graspedPoseHandler;
1207 _graspedPoseHandler = value;
1214 if (_lazyKinematicGraspedMovement ==
null) {
1217 return _lazyKinematicGraspedMovement;
1221 private NonKinematicGraspedMovement _lazyNonKinematicGraspedMovement;
1222 private NonKinematicGraspedMovement _nonKinematicGraspedMovement {
1224 if (_lazyNonKinematicGraspedMovement ==
null) {
1225 _lazyNonKinematicGraspedMovement =
new NonKinematicGraspedMovement();
1227 return _lazyNonKinematicGraspedMovement;
1231 private IThrowHandler _throwHandler;
1235 if (_throwHandler ==
null) {
1238 return _throwHandler;
1241 _throwHandler = value;
1245 public void BeginGrasp(List<InteractionController> controllers) {
1246 _justGrasped =
true;
1256 _graspingControllers.Query().First().ReleaseGrasp();
1260 foreach (var controller
in controllers) {
1261 _graspingControllers.Add(controller);
1273 if (_graspingControllers.Count == controllers.Count) {
1277 _angularDragBeforeGrasp =
rigidbody.angularDrag;
1280 _wasKinematicBeforeGrasp =
rigidbody.isKinematic;
1297 public void EndGrasp(List<InteractionController> controllers) {
1298 if (_graspingControllers.Count == controllers.Count &&
isSuspended) {
1304 foreach (var controller
in controllers) {
1305 _graspingControllers.Remove(controller);
1320 foreach (var item
in _graspingControllers) {
1327 if (_graspingControllers.Count == 0) {
1330 rigidbody.angularDrag = _angularDragBeforeGrasp;
1333 rigidbody.isKinematic = _wasKinematicBeforeGrasp;
1335 if (controllers.Count == 1) {
1341 if (_justGrasped) _justGrasped =
false;
1347 Vector3 origPosition =
rigidbody.position;
1348 Quaternion origRotation =
rigidbody.rotation;
1349 Vector3 newPosition;
1350 Quaternion newRotation;
1355 new Pose(newPosition, newRotation),
1363 _justGrasped =
false;
1367 List<InteractionController> controllers) {
1373 this, _justGrasped);
1398 private bool _appliedForces =
false;
1417 _appliedForces =
false;
1438 includeInactiveObjects:
false);
1445 refreshInteractionColliderLayers();
1450 #region Interaction Layers
1452 private int _lastInteractionLayer = -1;
1453 private int _lastNoContactLayer = -1;
1455 private void initLayers() {
1456 refreshInteractionLayer();
1457 refreshNoContactLayer();
1467 private void refreshInteractionLayer() {
1472 private void refreshNoContactLayer() {
1477 private void fixedUpdateLayers() {
1478 using (
new ProfilerSample(
"Interaction Behaviour: fixedUpdateLayers")) {
1480 refreshInteractionLayer();
1481 refreshNoContactLayer();
1498 refreshInteractionColliderLayers();
1504 (
manager as IInternalInteractionManager).NotifyIntObjHasNewInteractionLayer(
this, oldInteractionLayer: _lastInteractionLayer,
1510 (
manager as IInternalInteractionManager).NotifyIntObjHasNewNoContactLayer(
this, oldNoContactLayer: _lastNoContactLayer,
1517 private void finalizeLayers() {
1519 (
manager as IInternalInteractionManager).NotifyIntObjRemovedNoContactLayer(
this,
noContactLayer,
false);
1520 (
manager as IInternalInteractionManager).RefreshLayersNow();
1533 private void refreshInteractionColliderLayers() {
1543 #region Locked Position (Joint) Checking
1545 private bool _isPositionLocked =
false;
1567 if ((
rigidbody.constraints & RigidbodyConstraints.FreezePositionX) > 0
1568 && (
rigidbody.constraints & RigidbodyConstraints.FreezePositionY) > 0
1569 && (
rigidbody.constraints & RigidbodyConstraints.FreezePositionZ) > 0) {
1570 _isPositionLocked =
true;
1574 _isPositionLocked =
false;
1576 Joint[] joints =
rigidbody.GetComponents<Joint>();
1577 foreach (var joint
in joints) {
1578 if (joint.connectedBody ==
null || joint.connectedBody.isKinematic) {
1579 if (joint is FixedJoint) {
1580 _isPositionLocked =
true;
1583 if (joint is HingeJoint) {
1584 _isPositionLocked =
true;
1590 if (joint is CharacterJoint) {
1591 _isPositionLocked =
true;
1594 ConfigurableJoint configJoint = joint as ConfigurableJoint;
1595 if (configJoint !=
null
1596 && (configJoint.xMotion == ConfigurableJointMotion.Locked
1597 || (configJoint.xMotion == ConfigurableJointMotion.Limited
1598 && configJoint.linearLimit.limit == 0F))
1599 && (configJoint.yMotion == ConfigurableJointMotion.Locked
1600 || (configJoint.yMotion == ConfigurableJointMotion.Limited
1601 && configJoint.linearLimit.limit == 0F))
1602 && (configJoint.zMotion == ConfigurableJointMotion.Locked
1603 || (configJoint.zMotion == ConfigurableJointMotion.Limited
1604 && configJoint.linearLimit.limit == 0F))) {
1605 _isPositionLocked =
true;
1615 #region Unity Events
1624 PerControllerHoverBegin = 110,
1625 PerControllerHoverEnd = 111,
1627 PrimaryHoverBegin = 120,
1628 PrimaryHoverEnd = 121,
1629 PrimaryHoverStay = 122,
1630 PerControllerPrimaryHoverBegin = 130,
1631 PerControllerPrimaryHoverEnd = 132,
1636 PerControllerGraspBegin = 150,
1637 PerControllerGraspEnd = 152,
1639 SuspensionBegin = 160,
1640 SuspensionEnd = 161,
1645 PerControllerContactBegin = 180,
1646 PerControllerContactEnd = 181
1649 private void InitUnityEvents() {
1682 private void setupCallback(ref Action action,
EventType type) {
1684 action += () => _eventTable.
Invoke((
int)type);
1687 action += () => { };
1691 private void setupCallback<T>(ref Action<T> action,
EventType type) {
1693 action += (h) => _eventTable.
Invoke((
int)type);
1696 action += (h) => { };
Causes any Colliders located on the same GameObject to be ignored by the Interaction Engine....
The Finger class represents a tracked finger.
The Hand class reports the physical characteristics of a detected hand.
List< Finger > Fingers
The list of Finger objects detected in this frame that are attached to this hand, given in order from...
bool HasUnityEvent(int enumValue)
void Invoke(int enumValue)
InteractionBehaviours are components that enable GameObjects to interact with interaction controllers...
Pose? latestScheduledGraspPose
Nonkinematic grasping motion applies clamped velocities to Interaction Behaviours when they are grasp...
SingleLayer noContactLayer
Vector3 _accumulatedAngularAcceleration
ReadonlyHashSet< InteractionController > hoveringControllers
Gets all of the interaction controllers hovering near this object, whether they are Leap hands or sup...
bool ReleaseFromGrasp()
Releases this object from the interaction controller currently grasping it, if it is grasped,...
void StayPrimaryHovered(List< InteractionController > controllers)
Action< InteractionController > OnSuspensionBegin
Called when the interaction controller that is grasping this interaction object loses tracking....
Action OnPrimaryHoverStay
Called every fixed (physics) frame in which one or more interaction controllers is primarily hovering...
virtual float GetHoverDistance(Vector3 worldPosition)
Returns a comparative distance to this interaction object. Calculated by finding the smallest distanc...
void EndHover(List< InteractionController > controllers)
IgnoreHoverMode ignoreHoverMode
List< Collider > _interactionColliders
IGraspedPoseHandler graspedPoseHandler
Gets or sets the grasped pose handler for this Interaction object.
virtual void OnValidate()
ContactForceMode contactForceMode
void SetKinematicWithoutGrasp(bool isKinematic)
Use this if you want to modify the isKinematic state of an interaction object while it is grasped; ot...
InteractionController primaryHoveringController
Gets the closest primary hovering interaction controller for this object, if it has one....
Action OnGraspStay
Called every fixed (physics) frame during which this object is grasped by one or more hands.
Action OnGraspBegin
Called when the object becomes grasped, if it was not already held by any interaction controllers on ...
void BeginSuspension(InteractionController controller)
void RefreshPositionLockedState()
Call this method if the InteractionBehaviour's Rigidbody becomes or unbecomes fully positionally lock...
IThrowHandler throwHandler
Gets or sets the throw handler for this Interaction object.
Action OnContactStay
Called every frame during which one or more interaction controllers is colliding with this object.
Action< InteractionController > OnSuspensionEnd
Called when an object ceases being suspended. An object is suspended if it is currently grasped by an...
Action< InteractionController > OnPerControllerHoverEnd
Called whenever an interaction controller leaves the hover activity radius around this interaction ob...
void StayContacted(List< InteractionController > controllers)
bool GetKinematicWithoutGrasp()
Use this to retrieve the isKinematic state of the interactino object ignoring any temporary modificat...
void StayGrasped(List< InteractionController > controllers)
Action< InteractionController > OnPerControllerContactBegin
Called whenever an interaction controller begins colliding with this object.
Action< InteractionController > OnPerControllerPrimaryHoverEnd
Called whenever an interaction controler (a Leap hand or supported VR controller) stops primarily hov...
ReadonlyHashSet< InteractionController > graspingControllers
Gets the set of all interaction controllers currently grasping this object. Interaction controllers i...
Rigidbody rigidbody
The Rigidbody associated with this interaction object.
void RefreshInteractionColliders()
Recursively searches the hierarchy of this Interaction object to find all of the Colliders that are a...
virtual void fixedUpdateGraspedMovement(Pose origPose, Pose newPose, List< InteractionController > controllers)
GraspedMovementType graspedMovementType
ReadonlyHashSet< InteractionController > contactingControllers
Gets a set of all InteractionControllers currently contacting this interaction object.
bool moveObjectWhenGrasped
void EndGrasp(List< InteractionController > controllers)
bool isPrimaryHovered
Gets whether this object is the primary hover for any interaction controller.
void FixedUpdateObject()
The InteractionManager manually calls method this after all InteractionControllerBase objects are upd...
SingleLayer interactionLayer
ReadonlyHashSet< InteractionHand > graspingHands
Gets a set of all Leap hands currently grasping this object.
void EndPrimaryHover(List< InteractionController > controllers)
void AddAngularAcceleration(Vector3 acceleration)
Adds an angular acceleration to the center of mass of this object. Use this instead of Rigidbody....
Action< InteractionController > OnPerControllerGraspEnd
Called whenever an interaction controller stops grasping this object.
Action< InteractionController > OnPerControllerPrimaryHoverBegin
Called whenever an interaction controller (a Leap hand or supported VR controller) begins primarily h...
Finger primaryHoveringFinger
Gets the finger that is currently primarily hovering over this object, of the closest primarily hover...
void ClearContactTracking()
Clears contact tracking for this object on any currently-contacting controllers. If the object is sti...
InteractionController graspingController
Gets the controller currently grasping this object. Warning: If allowMultigrasp is enabled on this ob...
void StayHovered(List< InteractionController > controllers)
Action OnContactEnd
Called when the object ceases colliding with any interaction controllers, if the object was collidi...
Action OnHoverStay
Called during every fixed (physics) frame in which one or more interaction controller is within the h...
Vector3 _accumulatedLinearAcceleration
void ClearPrimaryHoverTracking()
Clears primary hover tracking state for this object on all of the currently- primary-hovering control...
InteractionController _suspendingController
void BeginGrasp(List< InteractionController > controllers)
Action OnPrimaryHoverEnd
Called when the object ceases being the primary hover of any interaction controllers,...
Action OnHoverBegin
Called when the object becomes hovered by any nearby interaction controllers. The hover activity radi...
ReadonlyHashSet< InteractionController > primaryHoveringControllers
Gets the set of all interaction controllers primarily hovering over this object.
void EndSuspension(InteractionController controller)
Action OnGraspEnd
Called when the object is no longer grasped by any interaction controllers.
bool isPositionLocked
Returns whether the InteractionBehaviour has its position fully locked by its Rigidbody settings or b...
bool overrideNoContactLayer
GraspedMovementEvent OnGraspedMovement
Called directly after this grasped object's Rigidbody has had its position and rotation set by its cu...
Action OnPrimaryHoverBegin
Called when the object becomes primarily hovered by any interaction controllers, if the object was no...
Action OnContactBegin
Called when this object begins colliding with any interaction controllers, if the object was not coll...
List< Collider > primaryHoverColliders
Gets the List of Colliders used for hover distance checking for this Interaction object....
bool isSuspended
Gets whether the object is currently suspended. An object is "suspended" if it is currently grasped b...
void BeginHover(List< InteractionController > controllers)
Vector3 GetGraspPoint(InteractionController intController)
Returns (approximately) where the argument hand is grasping this object. If the interaction controlle...
void EndContact(List< InteractionController > controllers)
bool isGrasped
Gets whether this object is grasped by any interaction controller.
void AddLinearAcceleration(Vector3 acceleration)
Adds a linear acceleration to the center of mass of this object. Use this instead of Rigidbody....
void BeginPrimaryHover(List< InteractionController > controllers)
const float MAX_ANGULAR_VELOCITY
bool isHovered
Gets whether any interaction controller is nearby.
void ClearHoverTracking(bool onlyInvalidControllers=false)
Clears hover tracking state for this object on all of the currently-hovering controllers....
Vector3 primaryHoveringControllerPoint
Gets the position of the primaryHoverPoint on the primary hovering interaction controller that is pri...
Hand primaryHoveringHand
Gets the primary hovering hand for this interaction object, if it has one. A hand is the primary hove...
float closestHoveringControllerDistance
Gets the distance from this object to the palm of the closest hand to this object,...
InteractionManager manager
Hand closestHoveringHand
Gets the closest Leap hand to this object, or null if no hand is nearby.
InteractionController closestHoveringController
Gets the closest interaction controller to this object, or null if no controller is nearby....
Action< InteractionController > OnPerControllerContactEnd
Called whenever an interaction controller stops colliding with this object.
float primaryHoverDistance
Gets the distance to the primary hover point whose controller is primarily hovering over this object....
Action< InteractionController > OnPerControllerGraspBegin
Called whenever an interaction controller grasps this object.
bool overrideInteractionLayer
Action< InteractionController > OnPerControllerHoverBegin
Called whenever an interaction controller enters the hover activity radius around this interaction ob...
Action OnHoverEnd
Called when the object stops being hovered by any nearby interaction controllers. The hover activity ...
void BeginContact(List< InteractionController > controllers)
bool ReleaseGrasp()
Releases the object this hand is holding and returns true if the hand was holding an object,...
Vector3 primaryHoveringPoint
Gets the position of the primary hovering point that is closest to its primary hovered object,...
int primaryHoveringPointIndex
Gets the index in the primaryHoverPoints array of the primary hover point that is currently closest t...
static void ReleaseGrasps(IInteractionBehaviour graspedObj, ReadonlyHashSet< InteractionController > controllers)
Helper static method for forcing multiple controllers to release their grasps on a single object simu...
abstract Vector3 GetGraspPoint()
Returns approximately where the controller is grasping the currently grasped InteractionBehaviour....
IInteractionBehaviour graspedObject
Gets the object the controller is currently grasping, or null if there is no such object.
float primaryHoverDistance
Gets the distance from the closest primary hover point on this controller to its primarily hovered ob...
Hand leapHand
Gets the last tracked state of the Leap hand.
bool UnregisterInteractionBehaviour(IInteractionBehaviour interactionObj)
Returns true if the Interaction Behaviour was registered with this manager; otherwise returns false....
bool IsBehaviourRegistered(IInteractionBehaviour interactionObj)
SingleLayer interactionLayer
void RegisterInteractionBehaviour(IInteractionBehaviour interactionObj)
static InteractionManager instance
Often, only one InteractionManager is necessary per Unity scene. This property will contain that Inte...
MultiGraspHoldingMode multiGraspHoldingMode
SingleLayer interactionNoContactLayer
This pose handler is the default implementation of IGraspedPoseHandler provided by the Interaction En...
This implementation of IGraspedMovementHandler moves its interaction object to a target position and ...
The sliding window throw handler implements a simple heuristic that provides a reasonably accurate me...
An IGraspedMovementHandler takes in a target position and rotation (a "pose", usually provided by an ...
void MoveTo(Vector3 solvedPosition, Quaternion solvedRotation, InteractionBehaviour interactionObj, bool justGrasped)
Called by an interaction object when its grasped pose handler has determined a target pose; this meth...
An IGraspedPoseHandler specifies where an object grasped by a Leap hand or controller (or multiple ha...
void ClearControllers()
Called e.g. if the InteractionBehaviour is set not to move while being grasped; this should clear any...
void GetGraspedPosition(out Vector3 position, out Quaternion rotation)
Calculate the best holding position and orientation given the current state of all InteractionControl...
void RemoveController(InteractionController controller)
Called when an InteractionController stops grasping a certain object; the controller should no longer...
void AddController(InteractionController controller)
Called when a new InteractionController begins grasping a certain object. The controller or Leap hand...
IInteractionBehaviour is the interface that defines all Interaction objects, specifying the minimum s...
Interaction objects feed their throw handlers callbacks when they are held (for data collection) and ...
void OnThrow(InteractionBehaviour intObj, InteractionController controller)
Called when an Interaction object is released by the last interaction controller holding it.
void OnHold(InteractionBehaviour intObj, ReadonlyList< InteractionController > controllers)
Called every FixedUpdate frame while an interaction object is being held.
delegate void GraspedMovementEvent(Vector3 oldPosition, Quaternion oldRotation, Vector3 newPosition, Quaternion newRotation, List< InteractionController > graspingControllers)
IgnoreHoverMode
Specified on a per-object basis to allow Interaction objects to ignore hover for the left hand,...
A position and rotation. You can multiply two poses; this acts like Matrix4x4 multiplication,...
A simple wrapper around HashSet to provide readonly access. Useful when you want to return a HashSet ...
An object you can use to represent a single Unity layer as a dropdown in the inspector....