public override void OnPose(PoseEvent e, bool isNew, Vector3 position, Quaternion rotation) { // Check that the pose is within visible view Vector3 screenPos = Camera.main.WorldToViewportPoint(position); // Only detect if the OnPose object is detected where the display is if (screenPos.x >= -0.25f && screenPos.x <= 1.25f && screenPos.y >= 0f && screenPos.y <= 1f) { CancelInvoke("LosePhysicalPose"); if (fingerObject == null) { // New pose: create the rigidbody object for it fingerObject = Instantiate(fingerPrefab, Camera.main.transform); fingerObject.transform.position = position; } else { // Smooth the motion of the kinematic rigidbody to ensure better // collision with buttons PositionLerp positionLerp = fingerObject.GetComponent <PositionLerp>(); if (positionLerp != null) { positionLerp.SetTarget(position); } } } else { // Don't loose it too fast as it might come back... if (!IsInvoking("LosePhysicalPose")) { Invoke("LosePhysicalPose", 0.5f); } } }