Esempio n. 1
0
        private void Ungrab(bool carryMomentum, uint controllerIndex, GameObject target)
        {
            OnPlayerClimbEnded(SetPlayerClimbEvent(controllerIndex, target));
            isClimbing = false;

            // Move to the last safe spot
            if (headsetColliding)
            {
                Vector3 headsetPosition = headCamera.transform.position;

                Vector3 moveVector    = lastGoodHeadsetPosition - headsetPosition;
                Vector3 moveDirection = moveVector.normalized;
                Vector3 moveOffset    = moveDirection * safeZoneTeleportOffset;

                transform.position += moveVector + moveOffset;
            }

            if (useGravity && carryMomentum)
            {
                Vector3 velocity = Vector3.zero;
                var     device   = VRTK_DeviceFinder.ControllerByIndex(controllerIndex);

                if (device)
                {
                    velocity = -device.GetComponent <VRTK_ControllerEvents>().GetVelocity();
                    if (usePlayerScale)
                    {
                        velocity = Vector3.Scale(velocity, transform.localScale);
                    }
                }

                playerPresence.StartPhysicsFall(velocity);
            }
            climbingObject = null;
        }
Esempio n. 2
0
        private void Ungrab(bool carryMomentum, uint controllerIndex, GameObject target)
        {
            OnPlayerClimbEnded(SetPlayerClimbEvent(controllerIndex, target));
            isClimbing = false;

            // Move to the last safe spot
            if (headsetColliding)
            {
                transform.position = lastGoodHeadsetPosition;
            }

            if (useGravity && carryMomentum)
            {
                var device = VRTK_DeviceFinder.ControllerByIndex(controllerIndex);
                playerPresence.StartPhysicsFall(-device.GetComponent <VRTK_ControllerEvents>().GetVelocity());
            }
        }