void HandHoverUpdate( VRHand hand ) { if ( hand.GetStandardInteractionButtonDown() ) { VRInputModule.instance.Submit( gameObject ); } }
void HandHoverUpdate(VRHand hand) { if (hand.GetStandardInteractionButtonDown()) { VRInputModule.instance.Submit(gameObject); } }
void OnDetachedFromHand(VRHand hand) { attached = false; hand.HoverUnlock(null); Rigidbody rb = GetComponent <Rigidbody>(); rb.isKinematic = false; rb.interpolation = RigidbodyInterpolation.Interpolate; velocityEstimator.FinishEstimatingVelocity(); Vector3 velocity = velocityEstimator.GetVelocityEstimate(); Vector3 angularVelocity = velocityEstimator.GetAngularVelocityEstimate(); rb.velocity = velocity; rb.angularVelocity = angularVelocity; // Make the object travel at the release velocity for the amount // of time it will take until the next fixed update, at which // point Unity physics will take over float timeUntilFixedUpdate = (Time.fixedDeltaTime + Time.fixedTime) - Time.time; transform.position += timeUntilFixedUpdate * velocity; float angle = Mathf.Rad2Deg * angularVelocity.magnitude; Vector3 axis = angularVelocity.normalized; transform.rotation *= Quaternion.AngleAxis(angle * timeUntilFixedUpdate, axis); }
//----------------------------------------------------- void HandHoverUpdate(VRHand hand) { if (hand.GetStandardInteractionButtonDown()) { PhysicsAttach(hand); } }
// Custom Inspector GUI allows us to click from within the UI public override void OnInspectorGUI() { DrawDefaultInspector(); VRHand vrHand = ( VRHand )target; if (vrHand.otherHand) { if (vrHand.otherHand.otherHand != vrHand) { UnityEditor.EditorGUILayout.HelpBox("The otherHand of this VRHand's otherHand is not this VRHand.", UnityEditor.MessageType.Warning); } if (vrHand.startingHandType == VRHand.HandType.Left && vrHand.otherHand.startingHandType != VRHand.HandType.Right) { UnityEditor.EditorGUILayout.HelpBox("This is a left VRHand but otherHand is not a right VRHand.", UnityEditor.MessageType.Warning); } if (vrHand.startingHandType == VRHand.HandType.Right && vrHand.otherHand.startingHandType != VRHand.HandType.Left) { UnityEditor.EditorGUILayout.HelpBox("This is a right VRHand but otherHand is not a left VRHand.", UnityEditor.MessageType.Warning); } if (vrHand.startingHandType == VRHand.HandType.Any && vrHand.otherHand.startingHandType != VRHand.HandType.Any) { UnityEditor.EditorGUILayout.HelpBox("This is an any-handed VRHand but otherHand is not an any-handed VRHand.", UnityEditor.MessageType.Warning); } } }
/// <summary> /// Called every Update() while a VRHand is hovering over me. /// </summary> /// <param name="hand"></param> void HandHoverUpdate(VRHand hand) { if (hand.GetStandardInteractionButtonDown() || ((hand.controller != null) && hand.controller.GetPressDown(Valve.VR.EVRButtonId.k_EButton_Grip))) { if (hand.currentAttachedObject != gameObject) { // Save our position/rotation so that we can restore it when we detach oldPosition = transform.position; oldRotation = transform.rotation; // Call this to continue receiving HandHoverUpdate messages, // and prevent the hand from hovering over anything else hand.HoverLock(GetComponent <VRInteractable>()); // Attach this object to the hand hand.AttachObject(gameObject, attachmentFlags); } else { // Detach this object from the hand hand.DetachObject(gameObject); // Call this to undo HoverLock hand.HoverUnlock(GetComponent <VRInteractable>()); // Restore position/rotation transform.position = oldPosition; transform.rotation = oldRotation; } } }
void OnHandHoverBegin( VRHand hand ) { bool showHint = true; // "Catch" the throwable by holding down the interaction button instead of pressing it. // Only do this if the throwable is moving faster than the prescribed threshold speed, // and if it isn't attached to another hand if ( !attached ) { if ( hand.GetStandardInteractionButton() ) { Rigidbody rb = GetComponent<Rigidbody>(); if ( rb.velocity.magnitude >= catchSpeedThreshold ) { hand.AttachObject( gameObject, attachmentFlags, attachmentPoint ); showHint = false; } } } if ( showHint ) { VRControllerButtonHints.Show( hand, Valve.VR.EVRButtonId.k_EButton_SteamVR_Trigger ); } }
void OnHandHoverBegin(VRHand hand) { bool showHint = true; // "Catch" the throwable by holding down the interaction button instead of pressing it. // Only do this if the throwable is moving faster than the prescribed threshold speed, // and if it isn't attached to another hand if (!attached) { if (hand.GetStandardInteractionButton()) { Rigidbody rb = GetComponent <Rigidbody>(); if (rb.velocity.magnitude >= catchSpeedThreshold) { hand.AttachObject(gameObject, attachmentFlags, attachmentPoint); showHint = false; } } } if (showHint) { VRControllerButtonHints.Show(hand, Valve.VR.EVRButtonId.k_EButton_SteamVR_Trigger); } }
//----------------------------------------------------- private bool PhysicsDetach(VRHand hand) { int i = holdingHands.IndexOf(hand); if (i != -1) { // Detach this object from the hand holdingHands[i].DetachObject(this.gameObject, false); // Allow the hand to do other things holdingHands[i].HoverUnlock(null); // Delete any existing joints from the hand if (attachMode == AttachMode.FixedJoint) { Destroy(holdingHands[i].GetComponent <FixedJoint>()); } FastRemove(holdingHands, i); FastRemove(holdingBodies, i); FastRemove(holdingPoints, i); return(true); } return(false); }
//----------------------------------------------------- void HandHoverUpdate( VRHand hand ) { if ( requireTriggerPress && hand.GetStandardInteractionButtonDown() ) { SpawnAndAttachObject( hand ); } }
void OnHandHoverBegin(VRHand hand) { anim.Play(); Globals.radioIsOn = !Globals.radioIsOn; Debug.Log(Globals.radioIsOn); }
/// <summary> /// Called every Update() while a VRHand is hovering over me. /// </summary> /// <param name="hand"></param> void HandHoverUpdate( VRHand hand ) { if ( hand.GetStandardInteractionButtonDown() || ( ( hand.controller != null ) && hand.controller.GetPressDown( Valve.VR.EVRButtonId.k_EButton_Grip ) ) ) { if ( hand.currentAttachedObject != gameObject ) { // Save our position/rotation so that we can restore it when we detach oldPosition = transform.position; oldRotation = transform.rotation; // Call this to continue receiving HandHoverUpdate messages, // and prevent the hand from hovering over anything else hand.HoverLock( GetComponent<VRInteractable>() ); // Attach this object to the hand hand.AttachObject( gameObject, false ); } else { // Detach this object from the hand hand.DetachObject( gameObject ); // Call this to undo HoverLock hand.HoverUnlock( GetComponent<VRInteractable>() ); // Restore position/rotation transform.position = oldPosition; transform.rotation = oldRotation; } } }
//----------------------------------------------------- void HandHoverUpdate(VRHand hand) { if (requireTriggerPress && hand.GetStandardInteractionButtonDown()) { SpawnAndAttachObject(hand); } }
void OnDrawGizmos() { if (this != instance) { return; } Gizmos.color = Color.green; Gizmos.DrawIcon(feetPositionGuess, "vr_interaction_system_feet.png"); Gizmos.color = Color.cyan; Gizmos.DrawLine(feetPositionGuess, feetPositionGuess + trackingOriginTransform.up * eyeHeight); // Body direction arrow Gizmos.color = Color.blue; Vector3 bodyDirection = bodyDirectionGuess; Vector3 bodyDirectionTangent = Vector3.Cross(trackingOriginTransform.up, bodyDirection); Vector3 startForward = feetPositionGuess + trackingOriginTransform.up * eyeHeight * 0.75f; Vector3 endForward = startForward + bodyDirection * 0.33f; Gizmos.DrawLine(startForward, endForward); Gizmos.DrawLine(endForward, endForward - 0.033f * (bodyDirection + bodyDirectionTangent)); Gizmos.DrawLine(endForward, endForward - 0.033f * (bodyDirection - bodyDirectionTangent)); Gizmos.color = Color.red; int count = handCount; for (int i = 0; i < count; i++) { VRHand hand = GetHand(i); if (hand.startingHandType == VRHand.HandType.Left) { Gizmos.DrawIcon(hand.transform.position, "vr_interaction_system_left_hand.png"); } else if (hand.startingHandType == VRHand.HandType.Right) { Gizmos.DrawIcon(hand.transform.position, "vr_interaction_system_right_hand.png"); } else { VRHand.HandType guessHandType = hand.GuessCurrentHandType(); if (guessHandType == VRHand.HandType.Left) { Gizmos.DrawIcon(hand.transform.position, "vr_interaction_system_left_hand_question.png"); } else if (guessHandType == VRHand.HandType.Right) { Gizmos.DrawIcon(hand.transform.position, "vr_interaction_system_right_hand_question.png"); } else { Gizmos.DrawIcon(hand.transform.position, "vr_interaction_system_unknown_hand.png"); } } Gizmos.DrawIcon(hand.transform.position, "right_hand_question.png"); } }
void OnDetachedFromHand( VRHand hand ) { attached = false; hand.HoverUnlock( null ); Rigidbody rb = GetComponent<Rigidbody>(); rb.isKinematic = false; rb.interpolation = RigidbodyInterpolation.Interpolate; velocityEstimator.FinishEstimatingVelocity(); Vector3 velocity = velocityEstimator.GetVelocityEstimate(); Vector3 angularVelocity = velocityEstimator.GetAngularVelocityEstimate(); rb.velocity = velocity; rb.angularVelocity = angularVelocity; // Make the object travel at the release velocity for the amount // of time it will take until the next fixed update, at which // point Unity physics will take over float timeUntilFixedUpdate = ( Time.fixedDeltaTime + Time.fixedTime ) - Time.time; transform.position += timeUntilFixedUpdate * velocity; float angle = Mathf.Rad2Deg * angularVelocity.magnitude; Vector3 axis = angularVelocity.normalized; transform.rotation *= Quaternion.AngleAxis( angle * timeUntilFixedUpdate, axis ); }
void HandAttachedUpdate(VRHand hand) { //Trigger got released if (hand.GetStandardInteractionButtonUp()) { hand.DetachObject(gameObject); } }
void HandAttachedUpdate( VRHand hand ) { //Trigger got released if ( hand.GetStandardInteractionButtonUp() ) { hand.DetachObject( gameObject ); } }
void HandHoverUpdate(VRHand hand) { //Trigger got pressed if (hand.GetStandardInteractionButtonDown()) { hand.AttachObject(gameObject, snapOnAttach, attachmentPoint, detachOthers); } }
void HandHoverUpdate( VRHand hand ) { //Trigger got pressed if ( hand.GetStandardInteractionButtonDown() ) { hand.AttachObject( gameObject, snapOnAttach, attachmentPoint, detachOthers ); } }
//----------------------------------------------------- void OnHandHoverBegin(VRHand hand) { Debug.Log("OnHoverBegin"); if (!requireTriggerPress) { SpawnAndAttachObject(hand); } }
//----------------------------------------------------- void OnHandHoverBegin( VRHand hand ) { Debug.Log( "OnHoverBegin" ); if ( !requireTriggerPress ) { SpawnAndAttachObject( hand ); } }
void HandHoverUpdate( VRHand hand ) { //Trigger got pressed if ( hand.GetStandardInteractionButtonDown() ) { hand.AttachObject( gameObject, attachmentFlags, attachmentPoint ); VRControllerButtonHints.Hide( hand ); } }
void HandHoverUpdate(VRHand hand) { //Trigger got pressed if (hand.GetStandardInteractionButtonDown()) { hand.AttachObject(gameObject, attachmentFlags, attachmentPoint); VRControllerButtonHints.Hide(hand); } }
//----------------------------------------------------- private void SpawnAndAttachObject(VRHand hand) { if (!alreadySpawned) { GameObject objectToAttach = GameObject.Instantiate(objectToSpawn); hand.AttachObject(objectToAttach, snapOnAttach, attachmentPoint, detachOthers); alreadySpawned = true; } }
//----------------------------------------------------- void OnHandHoverEnd(VRHand hand) { if (holdingHands.IndexOf(hand) == -1) { if (hand.controller != null) { hand.controller.TriggerHapticPulse(500); } } }
//----------------------------------------------------- private void SpawnAndAttachObject( VRHand hand ) { if ( !alreadySpawned ) { GameObject objectToAttach = GameObject.Instantiate( objectToSpawn ); hand.AttachObject( objectToAttach, snapOnAttach, attachmentPoint, detachOthers ); alreadySpawned = true; } }
public static void Show(VRHand hand, params Valve.VR.EVRButtonId[] buttons) { if (hand != null) { VRControllerButtonHints hints = hand.GetComponentInChildren <VRControllerButtonHints>(); if (hints != null) { hints.Show(buttons); } } }
void OnHandHoverBegin(VRHand hand) { if(Globals.ritualSequence.Count >= 3) { Globals.ritualSequence[2] = true; } anim.Play(); pianoAudio.Play(); Globals.buttonPressed = !Globals.buttonPressed; Debug.Log(Globals.buttonPressed); }
void OnHandHoverBegin(VRHand hand) { if (Globals.ritualSequence.Count >= 3) { Globals.ritualSequence[2] = true; } anim.Play(); pianoAudio.Play(); Globals.buttonPressed = !Globals.buttonPressed; Debug.Log(Globals.buttonPressed); }
public static void Hide(VRHand hand) { if (hand != null) { VRControllerButtonHints hints = hand.GetComponentInChildren <VRControllerButtonHints>(); if (hints != null) { hints.Hide(); } } }
void OnAttachedToHand( VRHand hand ) { attached = true; hand.HoverLock( null ); Rigidbody rb = GetComponent<Rigidbody>(); rb.isKinematic = true; rb.interpolation = RigidbodyInterpolation.None; velocityEstimator.BeginEstimatingVelocity(); }
//----------------------------------------------------- public void PhysicsAttach(VRHand hand) { PhysicsDetach(hand); Rigidbody holdingBody = null; Vector3 holdingPoint = Vector3.zero; // The hand should grab onto the nearest rigid body float closestDistance = float.MaxValue; for (int i = 0; i < rigidBodies.Count; i++) { float distance = Vector3.Distance(rigidBodies[i].worldCenterOfMass, hand.transform.position); if (distance < closestDistance) { holdingBody = rigidBodies[i]; closestDistance = distance; } } // Couldn't grab onto a body if (holdingBody == null) { return; } // Create a fixed joint from the hand to the holding body if (attachMode == AttachMode.FixedJoint) { Rigidbody handRigidbody = FindOrAddComponent <Rigidbody>(hand.gameObject); handRigidbody.isKinematic = true; FixedJoint handJoint = hand.gameObject.AddComponent <FixedJoint>(); handJoint.connectedBody = holdingBody; } // Don't let the hand interact with other things while it's holding us hand.HoverLock(null); // Affix this point Vector3 offset = hand.transform.position - holdingBody.worldCenterOfMass; offset = Mathf.Min(offset.magnitude, 1.0f) * offset.normalized; holdingPoint = holdingBody.transform.InverseTransformPoint(holdingBody.worldCenterOfMass + offset); hand.AttachObject(this.gameObject, attachmentFlags); // Update holding list holdingHands.Add(hand); holdingBodies.Add(holdingBody); holdingPoints.Add(holdingPoint); }
void OnAttachedToHand(VRHand hand) { attached = true; hand.HoverLock(null); Rigidbody rb = GetComponent <Rigidbody>(); rb.isKinematic = true; rb.interpolation = RigidbodyInterpolation.None; velocityEstimator.BeginEstimatingVelocity(); }
void OnDetachedFromHand( VRHand hand ) { attached = false; hand.HoverUnlock( null ); Rigidbody rb = GetComponent<Rigidbody>(); rb.isKinematic = false; rb.interpolation = RigidbodyInterpolation.Interpolate; velocityEstimator.FinishEstimatingVelocity(); rb.velocity = velocityEstimator.GetVelocityEstimate(); rb.angularVelocity = velocityEstimator.GetAngularVelocityEstimate(); }
void OnHandHoverBegin(VRHand hand) { if (!activated) { anim.Play(); coffeeAreaCollider.enabled = true; coffeeFlowRenderer.enabled = true; thisRenderer.material = usedMaterial; activated = true; Debug.Log("Enabled Coffee Area Collider"); coffeeFlowAudioSource.Play(); endTime = timeValidSeconds + Time.time; } }
void HandAttachedUpdate(VRHand hand) { //Trigger got released if (hand.GetStandardInteractionButtonUp()) { // Detach ourselves late in the frame. // This is so that any vehicles the player is attached to // have a chance to finish updating themselves. // If we detach now, our position could be behind what it // will be at the end of the frame, and the object may appear // to teleport behind the hand when the player releases it. StartCoroutine(LateDetach(hand)); } }
public void OnTriggerExit(Collider other) { VRHand hand = other.GetComponent <VRHand>(); if (hand != null) { animator.SetBool("isPressed", false); if (OnButtonReleased != null) { OnButtonReleased.Invoke(); } } }
void Update() { for (int i = 0; i < VRPlayer.instance.handCount; i++) { VRHand hand = VRPlayer.instance.GetHand(i); if (hand.controller != null) { if (hand.controller.GetPressDown(Valve.VR.EVRButtonId.k_EButton_SteamVR_Trigger)) { onTriggerDown.Invoke(); } if (hand.controller.GetPressUp(Valve.VR.EVRButtonId.k_EButton_SteamVR_Trigger)) { onTriggerUp.Invoke(); } if (hand.controller.GetPressDown(Valve.VR.EVRButtonId.k_EButton_Grip)) { onGripDown.Invoke(); } if (hand.controller.GetPressUp(Valve.VR.EVRButtonId.k_EButton_Grip)) { onGripUp.Invoke(); } if (hand.controller.GetPressDown(Valve.VR.EVRButtonId.k_EButton_SteamVR_Touchpad)) { onTouchpadDown.Invoke(); } if (hand.controller.GetPressUp(Valve.VR.EVRButtonId.k_EButton_SteamVR_Touchpad)) { onTouchpadUp.Invoke(); } if (hand.controller.GetTouchDown(Valve.VR.EVRButtonId.k_EButton_SteamVR_Touchpad)) { onTouchpadTouch.Invoke(); } if (hand.controller.GetTouchUp(Valve.VR.EVRButtonId.k_EButton_SteamVR_Touchpad)) { onTouchpadRelease.Invoke(); } } } }
void OnDetachedFromHand(VRHand hand) { attached = false; hand.HoverUnlock(null); Rigidbody rb = GetComponent <Rigidbody>(); rb.isKinematic = false; rb.interpolation = RigidbodyInterpolation.Interpolate; velocityEstimator.FinishEstimatingVelocity(); rb.velocity = velocityEstimator.GetVelocityEstimate(); rb.angularVelocity = velocityEstimator.GetAngularVelocityEstimate(); }
void Start() { VRHand[] hands = GetComponentsInChildren <VRHand>(); for (int i = 0; i < hands.Length; i++) { if (hands[i].hand == VRHand.ControllerIndex.Left) { leftHand = hands[i]; } else if (hands[i].hand == VRHand.ControllerIndex.Right) { rightHand = hands[i]; } } }
private VRHand thisHand; // Referencia a la mano para detectar si estamos pulsando un botón o no. /// <summary> /// Evento Start de MonoBehavior. /// Se ejecuta una vez al inicio. /// </summary> virtual public void Start() { if (reticle == null) { return; } // El componente Selection.cs también está pensado para estar asociado a la cámara. uiSelection = GetComponent <UISelection>(); // Almacenamos el tamaño y la orientación original de la retícula. originalScale = reticle.localScale; originalRotation = reticle.localRotation; thisHand = GetComponent <VRHand>(); }
void OnEnable() { _hand = (VRHand)target; AToggle = _hand.UseAxis; BToggle = _hand.UseButton; grabPointProperty = serializedObject.FindProperty("GrabPoint"); deviceIDProperty = serializedObject.FindProperty("DeviceID"); animProperty = serializedObject.FindProperty("Animator"); grabModeProperty = serializedObject.FindProperty("grabMode"); useAxisProperty = serializedObject.FindProperty("UseAxis"); axisIDProperty = serializedObject.FindProperty("GrabAxis"); grabThresholdProperty = serializedObject.FindProperty("GrabThreshold"); useButtonProperty = serializedObject.FindProperty("UseButton"); buttonIDProperty = serializedObject.FindProperty("GrabButton"); grabSpeedProperty = serializedObject.FindProperty("GrabSpeed"); }
void HandHoverUpdate ( VRHand hand ) { if ( hand.controller != null ) { SteamVR_Controller.Device controller = hand.controller; if ( controller.GetPressDown( Valve.VR.EVRButtonId.k_EButton_SteamVR_Trigger ) ) { onTriggerDown.Invoke(); } if ( controller.GetPressUp( Valve.VR.EVRButtonId.k_EButton_SteamVR_Trigger ) ) { onTriggerUp.Invoke(); } if ( controller.GetPressDown( Valve.VR.EVRButtonId.k_EButton_Grip ) ) { onGripDown.Invoke(); } if ( controller.GetPressUp( Valve.VR.EVRButtonId.k_EButton_Grip ) ) { onGripUp.Invoke(); } if ( controller.GetPressDown( Valve.VR.EVRButtonId.k_EButton_SteamVR_Touchpad ) ) { onTouchpadDown.Invoke(); } if ( controller.GetPressUp( Valve.VR.EVRButtonId.k_EButton_SteamVR_Touchpad ) ) { onTouchpadUp.Invoke(); } if ( controller.GetTouchDown( Valve.VR.EVRButtonId.k_EButton_SteamVR_Touchpad ) ) { onTouchpadTouch.Invoke(); } if ( controller.GetTouchUp( Valve.VR.EVRButtonId.k_EButton_SteamVR_Touchpad ) ) { onTouchpadRelease.Invoke(); } } }
void HandHoverUpdate(VRHand hand) { if (hand.controller != null) { SteamVR_Controller.Device controller = hand.controller; if (controller.GetPressDown(Valve.VR.EVRButtonId.k_EButton_SteamVR_Trigger)) { onTriggerDown.Invoke(); } if (controller.GetPressUp(Valve.VR.EVRButtonId.k_EButton_SteamVR_Trigger)) { onTriggerUp.Invoke(); } if (controller.GetPressDown(Valve.VR.EVRButtonId.k_EButton_Grip)) { onGripDown.Invoke(); } if (controller.GetPressUp(Valve.VR.EVRButtonId.k_EButton_Grip)) { onGripUp.Invoke(); } if (controller.GetPressDown(Valve.VR.EVRButtonId.k_EButton_SteamVR_Touchpad)) { onTouchpadDown.Invoke(); } if (controller.GetPressUp(Valve.VR.EVRButtonId.k_EButton_SteamVR_Touchpad)) { onTouchpadUp.Invoke(); } if (controller.GetTouchDown(Valve.VR.EVRButtonId.k_EButton_SteamVR_Touchpad)) { onTouchpadTouch.Invoke(); } if (controller.GetTouchUp(Valve.VR.EVRButtonId.k_EButton_SteamVR_Touchpad)) { onTouchpadRelease.Invoke(); } } }
void OnHandHoverBegin( VRHand hand ) { // "Catch" the throwable by holding down the interaction button instead of pressing it. // Only do this if the throwable is moving faster than the prescribed threshold speed, // and if it isn't attached to another hand if ( !attached ) { if ( hand.GetStandardInteractionButton() ) { Rigidbody rb = GetComponent<Rigidbody>(); if ( rb.velocity.magnitude >= catchSpeedThreshold ) { hand.AttachObject( gameObject, snapOnAttach, attachmentPoint, detachOthers ); } } } }
void OnHandHoverBegin(VRHand hand) { // "Catch" the throwable by holding down the interaction button instead of pressing it. // Only do this if the throwable is moving faster than the prescribed threshold speed, // and if it isn't attached to another hand if (!attached) { if (hand.GetStandardInteractionButton()) { Rigidbody rb = GetComponent <Rigidbody>(); if (rb.velocity.magnitude >= catchSpeedThreshold) { hand.AttachObject(gameObject, snapOnAttach, attachmentPoint, detachOthers); } } } }
void HandHoverUpdate( VRHand hand ) { if ( hand.currentAttachedObject ) return; if ( hand.GetStandardInteractionButtonDown() ) { hand.HoverLock( GetComponent<VRInteractable>() ); } if ( hand.GetStandardInteractionButtonUp() ) { hand.HoverUnlock( GetComponent<VRInteractable>() ); } if ( hand.GetStandardInteractionButton() ) { UpdateLinearMapping( hand.transform ); } }
void HandHoverUpdate( VRHand hand ) { if ( hand.GetStandardInteractionButtonDown() ) { hand.HoverLock( GetComponent<VRInteractable>() ); initialMappingOffset = linearMapping.value - CalculateLinearMapping( hand.transform ); sampleCount = 0; mappingChangeRate = 0.0f; } if ( hand.GetStandardInteractionButtonUp() ) { hand.HoverUnlock( GetComponent<VRInteractable>() ); CalculateMappingChangeRate(); } if ( hand.GetStandardInteractionButton() ) { UpdateLinearMapping( hand.transform ); } }
void OnDetachedFromHand( VRHand hand ) { attached = false; hand.HoverUnlock( null ); Rigidbody rb = GetComponent<Rigidbody>(); rb.isKinematic = false; rb.interpolation = RigidbodyInterpolation.Interpolate; velocityEstimator.FinishEstimatingVelocity(); Vector3 velocity = velocityEstimator.GetVelocityEstimate(); Vector3 angularVelocity = velocityEstimator.GetAngularVelocityEstimate(); rb.velocity = velocity; rb.angularVelocity = angularVelocity; // Make the object travel at the release velocity for the amount // of time it will take until the next fixed update, at which // point physics will happily take over simulation float t = ( Time.fixedDeltaTime + Time.fixedTime ) - Time.time; transform.position += t * velocity; // TODO: update transform.rotation? probably too subtle, but should be fixed // TODO: verify the fix using large fixed timestep, determine if the warning should be deleted }
/// <summary> /// Called when a VRHand stops hovering over me. /// </summary> /// <param name="hand"></param> void OnHandHoverEnd( VRHand hand ) { textMesh.text = "No Hand Hovering"; }
/// <summary> /// Called every Update() while our GameObject is attached to the hand /// </summary> /// <param name="hand"></param> void HandAttachedUpdate( VRHand hand ) { }
/// <summary> /// Called when our GameObject detaches from the hand /// </summary> /// <param name="hand"></param> void OnDetachedFromHand( VRHand hand ) { textMesh.text = "Detached from hand: " + hand.name; }
/// <summary> /// Called when our GameObject becomes attached to the hand /// </summary> /// <param name="hand"></param> void OnAttachedToHand( VRHand hand ) { textMesh.text = "Attached to hand: " + hand.name; }
//----------------------------------------------------- void OnHandHoverEnd( VRHand hand ) { Debug.Log( "OnHandHoverEnd" ); alreadySpawned = false; }
/// <summary> /// Called when our attached GameObject becomes the primary attached object /// </summary> /// <param name="hand"></param> void OnHandFocusAcquired( VRHand hand ) { }
/// <summary> /// Called when a VRHand starts hovering over me. /// </summary> /// <param name="hand"></param> void OnHandHoverBegin( VRHand hand ) { textMesh.text = "Hovering hand: " + hand.name; }
void OnHandHoverBegin(VRHand hand) { anim.Play(); Globals.buttonPressed = !Globals.buttonPressed; }
/// <summary> /// Called when another attached GameObject becomes the primary attached object /// </summary> /// <param name="hand"></param> void OnHandFocusLost( VRHand hand ) { }