public virtual void GetReleaseVelocities(Hand hand, out Vector3 velocity, out Vector3 angularVelocity) { switch (releaseVelocityStyle) { case ReleaseStyle.ShortEstimation: velocityEstimator.FinishEstimatingVelocity(); velocity = velocityEstimator.GetVelocityEstimate(); angularVelocity = velocityEstimator.GetAngularVelocityEstimate(); break; case ReleaseStyle.AdvancedEstimation: hand.GetEstimatedPeakVelocities(out velocity, out angularVelocity); break; case ReleaseStyle.GetFromHand: velocity = hand.GetTrackedObjectVelocity(releaseVelocityTimeOffset); angularVelocity = hand.GetTrackedObjectAngularVelocity(releaseVelocityTimeOffset); break; default: case ReleaseStyle.NoChange: velocity = rigidbody.velocity; angularVelocity = rigidbody.angularVelocity; break; } if (releaseVelocityStyle != ReleaseStyle.NoChange) { velocity *= scaleReleaseVelocity; } }
public virtual void GetReleaseVelocities(Hand hand, out Vector3 velocity, out Vector3 angularVelocity) { if (hand.noSteamVRFallbackCamera && releaseVelocityStyle != ReleaseStyle.NoChange) { releaseVelocityStyle = ReleaseStyle.ShortEstimation; // only type that works with fallback hand is short estimation. } switch (releaseVelocityStyle) { case ReleaseStyle.ShortEstimation: velocityEstimator.FinishEstimatingVelocity(); velocity = velocityEstimator.GetVelocityEstimate(); angularVelocity = velocityEstimator.GetAngularVelocityEstimate(); break; case ReleaseStyle.AdvancedEstimation: hand.GetEstimatedPeakVelocities(out velocity, out angularVelocity); break; case ReleaseStyle.GetFromHand: velocity = hand.GetTrackedObjectVelocity(releaseVelocityTimeOffset); angularVelocity = hand.GetTrackedObjectAngularVelocity(releaseVelocityTimeOffset); break; default: case ReleaseStyle.NoChange: velocity = rigidbody.velocity; angularVelocity = rigidbody.angularVelocity; break; } if (releaseVelocityStyle != ReleaseStyle.NoChange) { velocity *= scaleReleaseVelocity; } }
private void OnHandHoverBegin(Hand hand) { if (!broken) { if (hand.GetTrackedObjectVelocity().magnitude >= breakForce) { Break(); } } }
protected virtual void OnDetachedFromHand(Hand hand) { attachedHandleType = PageHandle.Type.None; if (rotateGameObject && rotateAfterDetach) { transform.localRotation = start * Quaternion.AngleAxis(outAngle, localPlaneNormal); } if (Book.pagePhysicsController != null) { Book.pagePhysicsController.PageDriveDetached(hand.GetTrackedObjectVelocity(), Book.pageMapping.value - lastMappingValue); } }
public virtual void GetReleaseVelocities(Hand hand, out Vector3 velocity, out Vector3 angularVelocity) { if (hand.noSteamVRFallbackCamera && releaseVelocityStyle != ReleaseStyle.NoChange) { releaseVelocityStyle = ReleaseStyle.ShortEstimation; // only type that works with fallback hand is short estimation. } switch (releaseVelocityStyle) { case ReleaseStyle.ShortEstimation: if (velocityEstimator != null) { velocityEstimator.FinishEstimatingVelocity(); velocity = velocityEstimator.GetVelocityEstimate(); angularVelocity = velocityEstimator.GetAngularVelocityEstimate(); } else { Debug.LogWarning("[SteamVR Interaction System] Throwable: No Velocity Estimator component on object but release style set to short estimation. Please add one or change the release style."); velocity = rigidbody.velocity; angularVelocity = rigidbody.angularVelocity; } break; case ReleaseStyle.AdvancedEstimation: hand.GetEstimatedPeakVelocities(out velocity, out angularVelocity); break; case ReleaseStyle.GetFromHand: velocity = hand.GetTrackedObjectVelocity(releaseVelocityTimeOffset); angularVelocity = hand.GetTrackedObjectAngularVelocity(releaseVelocityTimeOffset); break; default: case ReleaseStyle.NoChange: velocity = rigidbody.velocity; angularVelocity = rigidbody.angularVelocity; break; } if (releaseVelocityStyle != ReleaseStyle.NoChange) { float scaleFactor = 1.0f; if (scaleReleaseVelocityThreshold > 0) { scaleFactor = Mathf.Clamp01(scaleReleaseVelocityCurve.Evaluate(velocity.magnitude / scaleReleaseVelocityThreshold)); } velocity *= (scaleFactor * scaleReleaseVelocity); } }
private void HandAttachedUpdate(Hand hand) { // send signal for monster to dodge if (hand.GetTrackedObjectVelocity().magnitude > 2) { RaycastHit hit; if (Physics.Raycast(transform.position, transform.forward * 1.3f, out hit, 1)) { hit.transform.gameObject.SendMessage("Dodge", SendMessageOptions.DontRequireReceiver); StartCoroutine("HitRefresh"); } } if (canBeHit) { for (int i = 0; i < monsterColls.Length; i++) { if (coll.bounds.Intersects(monsterColls[i].bounds)) { Boxing mBoxing = monster.GetComponent <Boxing>(); if (mBoxing) { mBoxing.GetHit(true); StartCoroutine("HitRefresh"); } } } //if (otherColl) //{ // if (coll.bounds.Intersects(otherColl.bounds)) // { // Collider[] colls = otherColl.GetComponentsInChildren<Collider>(); // for (int i = 0; i < colls.Length; i++) // { // if (coll.bounds.Intersects(colls[i].bounds)) // { // Boxing mBoxing = colls[i].GetComponentInParent<Boxing>(); // if (mBoxing) // { // mBoxing.GetHit(true); // StartCoroutine("HitRefresh"); // } // } // } // } //} } }
private void HandAttachedUpdate(Hand hand) { //if ((rb.velocity + rb.angularVelocity).magnitude >= shakeThreshold) //{ //} shakeVel = (hand.GetTrackedObjectVelocity() + hand.GetTrackedObjectAngularVelocity()).magnitude; if (shakeVel >= shakeThreshold) { if (screenStatus != ScreenStatus.MainMenu) { screenStatus = ScreenStatus.MainMenu; } shakeVel = 0; } }
private InteractableDebug CreateSimulation(Hand fromHand, float timeOffset, Color copyColor) { GameObject copy = GameObject.Instantiate(this.gameObject); InteractableDebug debugCopy = copy.GetComponent <InteractableDebug>(); debugCopy.SetIsSimulation(); debugCopy.ColorSelf(copyColor); copy.name = string.Format("{0} [offset: {1:0.000}]", copy.name, timeOffset); Vector3 velocity = fromHand.GetTrackedObjectVelocity(timeOffset); velocity *= throwable.scaleReleaseVelocity; debugCopy.rigidbody.velocity = velocity; return(debugCopy); }
private void HandHoverUpdate(Hand hand) { if (hand.GetTrackedObjectVelocity().magnitude >= petVelocity && !canBeHit) { if (canBePet) { Debug.Log("petting monster"); StartCoroutine("PettingRefresh"); } } if (hand.GetStandardInteractionButtonDown()) { StartCoroutine("AddButtonPress"); if (buttonPresses > 2 && canBePet) { StartCoroutine("PettingRefresh"); buttonPresses = 0; } } }
private void OnHandHoverBegin(Hand hand) { if (canBeHit) { if (hand.GetStandardInteractionButton() && hand.GetTrackedObjectVelocity().magnitude >= hitVelocity) { if (hand.currentAttachedObject == null) { Debug.Log("monster got hit"); Boxing mBoxing = GetComponent <Boxing>(); if (mBoxing) { mBoxing.GetHit(false); StartCoroutine("HitRefresh"); } } } } }
public virtual void GetReleaseVelocities(Hand hand, out Vector3 velocity, out Vector3 angularVelocity) { switch (releaseVelocityStyle) { case ReleaseStyle.ShortEstimation: velocityEstimator.FinishEstimatingVelocity(); velocity = velocityEstimator.GetVelocityEstimate(); angularVelocity = velocityEstimator.GetAngularVelocityEstimate(); break; case ReleaseStyle.AdvancedEstimation: hand.GetEstimatedPeakVelocities(out velocity, out angularVelocity); break; case ReleaseStyle.GetFromHand: velocity = hand.GetTrackedObjectVelocity(releaseVelocityTimeOffset); angularVelocity = hand.GetTrackedObjectAngularVelocity(releaseVelocityTimeOffset); break; default: case ReleaseStyle.NoChange: velocity = rigidbody.velocity; angularVelocity = rigidbody.angularVelocity; break; } if (releaseVelocityStyle != ReleaseStyle.NoChange) { float scaleFactor = 1.0f; if (scaleReleaseVelocityThreshold > 0) { scaleFactor = Mathf.Clamp01(scaleReleaseVelocityCurve.Evaluate(velocity.magnitude / scaleReleaseVelocityThreshold)); } velocity *= scaleFactor * scaleReleaseVelocity; } }
//------------------------------------------------- private bool PhysicsDetach(Hand hand) { int i = holdingHands.IndexOf(hand); if (i != -1) { Vector3 vel = Vector3.zero; if (holdingHands.Count <= 1) { vel = hand.GetTrackedObjectVelocity(); } // 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>()); } Util.FastRemove(holdingHands, i); Util.FastRemove(holdingBodies, i); Util.FastRemove(holdingPoints, i); GetComponent <Rigidbody>().isKinematic = false; GetComponent <Rigidbody>().AddForce(vel * VelocityMult); return(true); } return(false); }
private void CreateMarker(Color markerColor, float destroyAfter = 10) { CreateMarker(markerColor, attachedToHand.GetTrackedObjectVelocity().normalized, destroyAfter); }