private void DoButtonOnePressed(object sender, ControllerInteractionEventArgs e) { DebugLogger(VRTK_ControllerReference.GetRealIndex(e.controllerReference), "BUTTON ONE", "pressed down", e); grapher.Invert(); }
public override void Grabbed(VRTK_InteractGrab grabbingObject) { base.Grabbed(grabbingObject); controllerReference = VRTK_ControllerReference.GetControllerReference(grabbingObject.controllerEvents.gameObject); }
protected override void OnEnable() { base.OnEnable(); controllerReference = null; interactableRigidbody.collisionDetectionMode = CollisionDetectionMode.Continuous; }
// Token: 0x06001E54 RID: 7764 RVA: 0x00099B58 File Offset: 0x00097D58 private void DoStartMenuReleased(object sender, ControllerInteractionEventArgs e) { this.DebugLogger(VRTK_ControllerReference.GetRealIndex(e.controllerReference), "START MENU", "released", e); }
// Token: 0x06001E57 RID: 7767 RVA: 0x00099BB2 File Offset: 0x00097DB2 private void DoControllerIndexChanged(object sender, ControllerInteractionEventArgs e) { this.DebugLogger(VRTK_ControllerReference.GetRealIndex(e.controllerReference), "CONTROLLER STATE", "INDEX CHANGED", e); }
// Token: 0x06001E4A RID: 7754 RVA: 0x00099A2C File Offset: 0x00097C2C private void DoTouchpadAxisChanged(object sender, ControllerInteractionEventArgs e) { this.DebugLogger(VRTK_ControllerReference.GetRealIndex(e.controllerReference), "TOUCHPAD", "axis changed", e); }
// Token: 0x06001E4F RID: 7759 RVA: 0x00099AC2 File Offset: 0x00097CC2 private void DoButtonTwoPressed(object sender, ControllerInteractionEventArgs e) { this.DebugLogger(VRTK_ControllerReference.GetRealIndex(e.controllerReference), "BUTTON TWO", "pressed down", e); }
private void DoGripAxisChanged(object sender, ControllerInteractionEventArgs e) { DebugLogger(VRTK_ControllerReference.GetRealIndex(e.controllerReference), "GRIP", "axis changed", e); }
private void DoTouchpadTouchEnd(object sender, ControllerInteractionEventArgs e) { DebugLogger(VRTK_ControllerReference.GetRealIndex(e.controllerReference), "TOUCHPAD", "untouched", e); }
void BroadcastHapticPulseOnViewID(int viewIdOfController, float vibrationStrength, float duration, float pulseInterval) { Debug.Log("Broadcast Haptic Pulse on this Controller: " + viewIdOfController); VRTK_ControllerHaptics.TriggerHapticPulse(VRTK_ControllerReference.GetControllerReference(PhotonView.Find(viewIdOfController).gameObject), vibrationStrength, duration, pulseInterval); }
private void DoGripTouchStart(object sender, ControllerInteractionEventArgs e) { DebugLogger(VRTK_ControllerReference.GetRealIndex(e.controllerReference), "GRIP", "touched", e); }
/// <summary> /// Call Back of hitboxes /// </summary> /// <param name="hitBox">vHitBox object</param> /// <param name="other">target Collider</param> public void OnHit(VRHitBox hitBox, Collider other) { if (meleeManager == null) { return; } VRTK_ControllerReference controllerReference = VRTK_ControllerReference.GetControllerReference(meleeManager.GetControllerGameObject(this)); var collisionForce = VRTK_DeviceFinder.GetControllerVelocity(controllerReference).magnitude *powerMult; if (collisionForce < power.x) { return; } float percPowerValue = collisionForce > power.y ? 1 : ((collisionForce - power.x) / (power.y - power.x)); VRTK_ControllerHaptics.TriggerHapticPulse(controllerReference, MaxHapticValue * percPowerValue, 0.03f, 0.01f); //Check first contition for hit if (canApplyDamage && (meleeManager != null && other.gameObject != meleeManager.gameObject)) { var inDamage = false; //check if meleeManager exist and apply his hitProperties to this List <string> _hitDamageTags = meleeManager.hitDamageTags; /// Damage Conditions if (_hitDamageTags == null || _hitDamageTags.Count == 0) { inDamage = true; } else if (_hitDamageTags.Contains(other.tag)) { inDamage = true; } if (inDamage) { VRHitInfo hitInfo = new VRHitInfo(this, hitBox, other, hitBox.transform.position); // Creating new vDamage depending on hit power vDamage oldDamage = new vDamage(hitInfo.attackObject.damage); hitInfo.attackObject.damage.damageValue = Mathf.RoundToInt(hitInfo.attackObject.damage.damageValue * percPowerValue); if (inDamage == true) { /// If meleeManager /// call onDamageHit to control damage values /// and meleemanager will call the ApplyDamage after to filter the damage /// if meleeManager is null /// The damage will be directly applied /// Finally the OnDamageHit event is called if (meleeManager) { meleeManager.OnDamageHit(hitInfo); } else { // Creating new vDamage depending on hit power vDamage newDamage = new vDamage(damage); newDamage.sender = transform; newDamage.damageValue = Mathf.RoundToInt(newDamage.damageValue * percPowerValue); ApplyDamage(hitBox, other, newDamage); } if (onDamageHit != null) { onDamageHit.Invoke(hitInfo); } } hitInfo.attackObject.damage = oldDamage; } } }
//this object has been ungrabbed.. so do what ever is in the code private void ObjectUngrabbed(object sender, InteractableObjectEventArgs e) { Debug.Log("Im dropped"); controllerReference = null; }
private void DoTriggerPressed(object sender, ControllerInteractionEventArgs e) { DebugLogger(VRTK_ControllerReference.GetRealIndex(e.controllerReference), "TRIGGER", "pressed", e); gm.setRightTP(true); }
// Token: 0x06001E44 RID: 7748 RVA: 0x00099978 File Offset: 0x00097B78 private void DoGripUnclicked(object sender, ControllerInteractionEventArgs e) { this.DebugLogger(VRTK_ControllerReference.GetRealIndex(e.controllerReference), "GRIP", "unclicked", e); }
private void DoButtonOneTouchEnd(object sender, ControllerInteractionEventArgs e) { SharedObjects.IsButton1Checked = true; DebugLogger(VRTK_ControllerReference.GetRealIndex(e.controllerReference), "BUTTON ONE", "untouched", e); }
// Token: 0x06001E46 RID: 7750 RVA: 0x000999B4 File Offset: 0x00097BB4 private void DoTouchpadPressed(object sender, ControllerInteractionEventArgs e) { this.DebugLogger(VRTK_ControllerReference.GetRealIndex(e.controllerReference), "TOUCHPAD", "pressed down", e); }
private void DoButtonTwoReleased(object sender, ControllerInteractionEventArgs e) { DebugLogger(VRTK_ControllerReference.GetRealIndex(e.controllerReference), "BUTTON TWO", "released", e); }
// Token: 0x06001E4D RID: 7757 RVA: 0x00099A86 File Offset: 0x00097C86 private void DoButtonOneTouchStart(object sender, ControllerInteractionEventArgs e) { this.DebugLogger(VRTK_ControllerReference.GetRealIndex(e.controllerReference), "BUTTON ONE", "touched", e); }
private void DoStartMenuPressed(object sender, ControllerInteractionEventArgs e) { DebugLogger(VRTK_ControllerReference.GetRealIndex(e.controllerReference), "START MENU", "pressed down", e); }
// Token: 0x06001E52 RID: 7762 RVA: 0x00099B1C File Offset: 0x00097D1C private void DoButtonTwoTouchEnd(object sender, ControllerInteractionEventArgs e) { this.DebugLogger(VRTK_ControllerReference.GetRealIndex(e.controllerReference), "BUTTON TWO", "untouched", e); }
private void DoTriggerReleased(object sender, ControllerInteractionEventArgs e) { DebugLogger(VRTK_ControllerReference.GetRealIndex(e.controllerReference), "TRIGGER", "released", e); }
// Token: 0x06001E56 RID: 7766 RVA: 0x00099B94 File Offset: 0x00097D94 private void DoControllerDisabled(object sender, ControllerInteractionEventArgs e) { this.DebugLogger(VRTK_ControllerReference.GetRealIndex(e.controllerReference), "CONTROLLER STATE", "DISABLED", e); }
//------------------------------------------------- //private void HandAttachedUpdate(Hand hand) private void Update() { if (!isGrab) { return; } // Reset transform since we cheated it right after getting poses on previous frame transform.localPosition = Vector3.zero; transform.localRotation = Quaternion.identity; // Update handedness guess //EvaluateHandedness(); if (nocked) { deferNewPoses = true; Vector3 nockToarrowHand = (arrowHand.arrowNockTransform.parent.position - nockRestTransform.position); // Vector from bow nock transform to arrowhand nock transform - used to align bow when drawing // Align bow // Time lerp value used for ramping into drawn bow orientation float lerp = Util.RemapNumberClamped(Time.time, nockLerpStartTime, (nockLerpStartTime + lerpDuration), 0f, 1f); float pullLerp = Util.RemapNumberClamped(nockToarrowHand.magnitude, minPull, maxPull, 0f, 1f); // Normalized current state of bow draw 0 - 1 //Vector3 arrowNockTransformToHeadset = ((Player.instance.hmdTransform.position + (Vector3.down * 0.05f)) - arrowHand.arrowNockTransform.parent.position).normalized; Vector3 arrowNockTransformToHeadset = ((VRTK_SDK_Bridge.GetHeadset().position + (Vector3.down * 0.05f)) - arrowHand.arrowNockTransform.parent.position).normalized; Vector3 arrowHandPosition = (arrowHand.arrowNockTransform.parent.position + ((arrowNockTransformToHeadset * drawOffset) * pullLerp)); // Use this line to lerp arrowHand nock position //Vector3 arrowHandPosition = arrowHand.arrowNockTransform.position; // Use this line if we don't want to lerp arrowHand nock position Vector3 pivotToString = (arrowHandPosition - pivotTransform.position).normalized; Vector3 pivotToLowerHandle = (handleTransform.position - pivotTransform.position).normalized; bowLeftVector = -Vector3.Cross(pivotToLowerHandle, pivotToString); pivotTransform.rotation = Quaternion.Lerp(nockLerpStartRotation, Quaternion.LookRotation(pivotToString, bowLeftVector), lerp); // Move nock position if (Vector3.Dot(nockToarrowHand, -nockTransform.forward) > 0) { float distanceToarrowHand = nockToarrowHand.magnitude * lerp; nockTransform.localPosition = new Vector3(0f, 0f, Mathf.Clamp(-distanceToarrowHand, -maxPull, 0f)); nockDistanceTravelled = -nockTransform.localPosition.z; arrowVelocity = Util.RemapNumber(nockDistanceTravelled, minPull, maxPull, arrowMinVelocity, arrowMaxVelocity); drawTension = Util.RemapNumberClamped(nockDistanceTravelled, 0, maxPull, 0f, 1f); //this.bowDrawLinearMapping.value = drawTension; // Send drawTension value to LinearMapping script, which drives the bow draw animation longBowAni.Play(0, 0, drawTension); if (nockDistanceTravelled > minPull) { pulled = true; } else { pulled = false; } if ((nockDistanceTravelled > (lastTickDistance + hapticDistanceThreshold)) || nockDistanceTravelled < (lastTickDistance - hapticDistanceThreshold)) { ushort hapticStrength = (ushort)Util.RemapNumber(nockDistanceTravelled, 0, maxPull, bowPullPulseStrengthLow, bowPullPulseStrengthHigh); ///手柄震动 VRTK_SDK_Bridge.HapticPulse(VRTK_ControllerReference.GetControllerReference(hand), hapticStrength); VRTK_SDK_Bridge.HapticPulse(VRTK_ControllerReference.GetControllerReference(otherHand), hapticStrength); //hand.controller.TriggerHapticPulse(hapticStrength); //hand.otherHand.controller.TriggerHapticPulse(hapticStrength); drawSound.PlayBowTensionClicks(drawTension); lastTickDistance = nockDistanceTravelled; } if (nockDistanceTravelled >= maxPull) { if (Time.time > nextStrainTick) { //hand.controller.TriggerHapticPulse(400); //hand.otherHand.controller.TriggerHapticPulse(400); VRTK_SDK_Bridge.HapticPulse(VRTK_ControllerReference.GetControllerReference(hand), 400); VRTK_SDK_Bridge.HapticPulse(VRTK_ControllerReference.GetControllerReference(otherHand), 400); drawSound.PlayBowTensionClicks(drawTension); nextStrainTick = Time.time + Random.Range(minStrainTickTime, maxStrainTickTime); } } } else { nockTransform.localPosition = new Vector3(0f, 0f, 0f); //this.bowDrawLinearMapping.value = 0f; longBowAni.Play(0, 0, 0); } } else { if (lerpBackToZeroRotation) { float lerp = Util.RemapNumber(Time.time, lerpStartTime, lerpStartTime + lerpDuration, 0, 1); pivotTransform.localRotation = Quaternion.Lerp(lerpStartRotation, Quaternion.identity, lerp); if (lerp >= 1) { lerpBackToZeroRotation = false; } } } }
// Token: 0x06001E37 RID: 7735 RVA: 0x000997F2 File Offset: 0x000979F2 private void DoTriggerTouchEnd(object sender, ControllerInteractionEventArgs e) { this.DebugLogger(VRTK_ControllerReference.GetRealIndex(e.controllerReference), "TRIGGER", "untouched", e); }
// Token: 0x06001E38 RID: 7736 RVA: 0x00099810 File Offset: 0x00097A10 private void DoTriggerHairlineStart(object sender, ControllerInteractionEventArgs e) { this.DebugLogger(VRTK_ControllerReference.GetRealIndex(e.controllerReference), "TRIGGER", "hairline start", e); }
public override void Ungrabbed(VRTK_InteractGrab previousGrabbingObject) { base.Ungrabbed(previousGrabbingObject); controllerReference = null; }
// Token: 0x06001E42 RID: 7746 RVA: 0x0009993C File Offset: 0x00097B3C private void DoGripHairlineEnd(object sender, ControllerInteractionEventArgs e) { this.DebugLogger(VRTK_ControllerReference.GetRealIndex(e.controllerReference), "GRIP", "hairline end", e); }
private VRTK_ControllerReference GetValue(Recursion arg1) { return(VRTK_ControllerReference.GetControllerReference(Hand.GetValue <SDK_BaseController.ControllerHand>())); }
protected virtual void ThrowReleasedObject(Rigidbody objectRigidbody) { if (grabbedObjectScript != null) { VRTK_ControllerReference controllerReference = VRTK_ControllerReference.GetControllerReference(grabbedObjectScript.GetGrabbingObject()); if (VRTK_ControllerReference.IsValid(controllerReference) && controllerReference.scriptAlias != null) { VRTK_InteractGrab grabbingObjectScript = controllerReference.scriptAlias.GetComponent <VRTK_InteractGrab>(); if (grabbingObjectScript != null) { Transform origin = VRTK_DeviceFinder.GetControllerOrigin(controllerReference); Vector3 velocity = VRTK_DeviceFinder.GetControllerVelocity(controllerReference); Vector3 angularVelocity = VRTK_DeviceFinder.GetControllerAngularVelocity(controllerReference); float grabbingObjectThrowMultiplier = grabbingObjectScript.throwMultiplier; if (origin != null) { objectRigidbody.velocity = origin.TransformVector(velocity) * (grabbingObjectThrowMultiplier * throwMultiplier); objectRigidbody.angularVelocity = origin.TransformDirection(angularVelocity); if (bow != null) { if (objectRigidbody.velocity.magnitude < 7.5f) { bow.Thrown(false); } else { bow.Thrown(); } print(objectRigidbody.velocity.magnitude); } else { Debug.Log("NO BOW SCRIPT!"); } } else { objectRigidbody.velocity = velocity * (grabbingObjectThrowMultiplier * throwMultiplier); objectRigidbody.angularVelocity = angularVelocity; } if (throwVelocityWithAttachDistance) { Collider rigidbodyCollider = objectRigidbody.GetComponentInChildren <Collider>(); if (rigidbodyCollider != null) { Vector3 collisionCenter = rigidbodyCollider.bounds.center; objectRigidbody.velocity = objectRigidbody.GetPointVelocity(collisionCenter + (collisionCenter - transform.position)); } else { objectRigidbody.velocity = objectRigidbody.GetPointVelocity(objectRigidbody.position + (objectRigidbody.position - transform.position)); } } } } } }