Пример #1
0
        protected override void OnFixedUpdate()
        {
            base.OnFixedUpdate();

            if (HasFocus(false) && _Controller.Tracking.isValid)
            {
                var device = GetInput();
                if (device.GetPressDown(EVRButtonId.k_EButton_SteamVR_Trigger))
                {
                    _PrevPos = transform.position;
                    _PrevRot = transform.rotation;
                    _Rumble.MilliInterval = 500;
                    _Dragging             = true;
                }
                if (device.GetPress(EVRButtonId.k_EButton_SteamVR_Trigger))
                {
                    _Manager.DriveMovePosition(transform.position - _PrevPos);

                    var rotDiff = (transform.rotation) * Quaternion.Inverse(_PrevRot);
                    _Manager.DriveMoveRotation(Quaternion.Inverse(_Manager.rotRoot.rotation) * rotDiff * _Manager.rotRoot.rotation);

                    _PrevPos = transform.position;
                    _PrevRot = transform.rotation;
                }
                if (device.GetPressUp(EVRButtonId.k_EButton_SteamVR_Trigger))
                {
                    _Dragging = false;

                    if (_Hover)
                    {
                        _Rumble.MilliInterval = 100;
                    }
                    else
                    {
                        Release();
                    }
                }
            }
        }
Пример #2
0
        protected override void OnFixedUpdate()
        {
            base.OnFixedUpdate();

            if (Tracking.isValid)
            {
                var device = Controller;
                if (device.GetPressDown(EVRButtonId.k_EButton_SteamVR_Trigger))
                {
                    _HoverObject = FindNearestHandle();
                    if (!_HoverObject)
                    {
                        return;
                    }

                    _Manager  = (_GuideDriveManager.GetValue(_HoverObject.GetComponent <GuideDrive>()) as GuideDriveManager);
                    _PrevPos  = transform.position;
                    _PrevRot  = transform.rotation;
                    _Dragging = true;
                    Owner.StartRumble(_Rumble);
                }
                if (_HoverObject)
                {
                    if (device.GetPress(EVRButtonId.k_EButton_SteamVR_Trigger))
                    {
                        _Manager.DriveMovePosition(transform.position - _PrevPos);

                        var rotDiff = (transform.rotation) * Quaternion.Inverse(_PrevRot);
                        _Manager.DriveMoveRotation(Quaternion.Inverse(_Manager.rotRoot.rotation) * rotDiff * _Manager.rotRoot.rotation);

                        _PrevPos = transform.position;
                        _PrevRot = transform.rotation;
                    }
                    if (device.GetPressUp(EVRButtonId.k_EButton_SteamVR_Trigger))
                    {
                        _Dragging = false;
                        Release();
                        Owner.StopRumble(_Rumble);
                    }
                }
                if (device.GetPressDown(EVRButtonId.k_EButton_SteamVR_Touchpad))
                {
                    if (IKCtrl.Visibility == IKCtrl.IKVisibility.Deactivated)
                    {
                        IKCtrl.Enable();
                    }
                    else
                    {
                        IKCtrl.Toggle();
                    }
                }
                if (device.GetPressDown(EVRButtonId.k_EButton_Grip))
                {
                    if (IKCtrl.Visibility == IKCtrl.IKVisibility.Deactivated)
                    {
                        IKCtrl.Enable();
                    }
                    else
                    {
                        IKCtrl.Disable();
                    }
                }
            }
        }