void TriggerPressed(object sender, ControllerInteractionEventArgs e) { if (dragState == State.Locked) { return; } GameObject controller = VRTK_DeviceFinder.GetActualController(((VRTK_ControllerEvents)sender).gameObject); if (bodyPhysics.OnGround()) { currentUsedController = controller; controllerDragStartLocalPos = currentUsedController.transform.localPosition; playAreaDragStartPos = playArea.position; bodyPhysics.ResetFalling(); bodyPhysics.TogglePreventSnapToFloor(true); bodyPhysics.enableBodyCollisions = false; bodyPhysics.ToggleOnGround(false); dragState = State.Active; } }
protected virtual void Release(GameObject actualController) { if (actualController == mPullingController) { BodyPhysics.ResetFalling(); mIsPulling = false; // Jumping Vector3 jumpVector = -mPullingVelocity; if (BodyPhysics.OnGround()) { if (jumpVector.y > JumpYThreshold) { BodyPhysics.ApplyBodyVelocity(jumpVector * JumpForceFactor, true, true); } } mPullingController = null; } }
private bool OnGround() { return(VRTK_bodyPhysics.OnGround()); }