private void Ungrab(bool carryMomentum, uint controllerIndex) { bodyPhysics.TogglePreventSnapToFloor(false); bodyPhysics.enableBodyCollisions = true; if (carryMomentum) { Vector3 velocity = Vector3.zero; var device = VRTK_DeviceFinder.GetControllerByIndex(controllerIndex, false); if (device) { velocity = -VRTK_DeviceFinder.GetControllerVelocity(device); if (usePlayerScale) { velocity = Vector3.Scale(velocity, playArea.localScale); } } Vector3 throwVelocity = Vector3.ClampMagnitude(velocity * throwMultiplier, maxSpeed); if (throwVelocity.y <= 1) { throwVelocity.y = 1; } bodyPhysics.ApplyBodyVelocity(throwVelocity * throwMultiplier, true, true); } isClimbing = false; grabbingController = null; OnPlayerClimbEnded(SetPlayerClimbEvent(controllerIndex)); }
private void Ungrab(bool carryMomentum, uint controllerIndex, GameObject target) { bodyPhysics.TogglePreventSnapToFloor(false); bodyPhysics.enableBodyCollisions = true; if (carryMomentum) { Vector3 velocity = Vector3.zero; var device = VRTK_DeviceFinder.GetControllerByIndex(controllerIndex, false); if (device) { velocity = -VRTK_DeviceFinder.GetControllerVelocity(device); if (usePlayerScale) { velocity = Vector3.Scale(velocity, playArea.localScale); } } bodyPhysics.ApplyBodyVelocity(velocity, true, true); } isClimbing = false; grabbingController = null; climbingObject = null; OnPlayerClimbEnded(SetPlayerClimbEvent(controllerIndex, target)); }
private void UngrabDisc(bool carryMomentum, uint controllerIndex) { if (carryMomentum) { Vector3 velocity = Vector3.zero; var device = VRTK_DeviceFinder.GetControllerByIndex(controllerIndex, false); grabbedDisc.transform.rotation = Quaternion.Euler(new Vector3(90, 0, 0)); if (device) { velocity = VRTK_DeviceFinder.GetControllerVelocity(device); if (usePlayerScale) { velocity = Vector3.Scale(velocity, playArea.localScale); } } grabbedDiscRb.angularVelocity = new Vector3(0.0f, 100.0f, 0.0f); grabbedDiscRb.constraints = RigidbodyConstraints.FreezeRotationX | RigidbodyConstraints.FreezeRotationY; Vector3 throwVelocity = (velocity * throwMultiplier); grabbedDiscRb.velocity = (velocity * throwMultiplier); releaseDir = throwVelocity.normalized; } releasedDisc = grabbedDisc; releasedDiscRb = grabbedDiscRb; releasePos = VRTK_DeviceFinder.GetControllerByIndex(controllerIndex, false).transform.position; StartCoroutine(CountdownReleaseDisc()); grabbedDisc = null; grabbedDiscRb = null; }
private void CurveAfterThrow() { var device = VRTK_DeviceFinder.GetControllerByIndex(controllerIndex, false); Vector3 curveDir = Vector3.Cross(releaseDir, Vector3.up); Vector3 difference = device.transform.position - releasePos; difference = Vector3.ProjectOnPlane(difference, releaseDir); releasedDiscRb.AddForce(difference * curveSpeed); }
// Token: 0x06001AAD RID: 6829 RVA: 0x0008CAF0 File Offset: 0x0008ACF0 protected virtual VRTK_UIPointer GetPointer(PointerEventData eventData) { GameObject controllerByIndex = VRTK_DeviceFinder.GetControllerByIndex((uint)eventData.pointerId, false); if (!(controllerByIndex != null)) { return(null); } return(controllerByIndex.GetComponent <VRTK_UIPointer>()); }
protected virtual VRTK_UIPointer GetPointer(PointerEventData eventData) { var controller = VRTK_DeviceFinder.GetControllerByIndex((uint)eventData.pointerId, false); return(controller ? controller.GetComponent <VRTK_UIPointer>() : null); }
protected virtual void EngageButtonPressed(object sender, ControllerInteractionEventArgs e) { engagedController = VRTK_DeviceFinder.GetControllerByIndex(e.controllerIndex, false); active = true; }