コード例 #1
0
 public override void Rotate(InputManager.Axis ax, float val)
 {
     if (Active)
     {
         if (ax == InputManager.Axis.X)
         {
             _gObj.transform.Rotate(val, 0.0f, 0.0f, Space.World);
         }
         if (ax == InputManager.Axis.Y)
         {
             _gObj.transform.Rotate(0.0f, val, 0.0f, Space.World);
         }
         else if (ax == InputManager.Axis.Z)
         {
             _gObj.transform.Rotate(0.0f, 0.0f, val, Space.World);
         }
         else
         {
             if (HubrisCore.Instance.Debug)
             {
                 LocalConsole.Instance.LogError("FPSPlayer Rotate(): Invalid Axis specified", true);
             }
         }
     }
 }
コード例 #2
0
        public override void Move(InputManager.Axis ax, float val)
        {
            if (Active)
            {
                _moving = true;

                SpeedTarget = CheckSpeedTarget();

                // Isolate the new movement vector requested
                Vector3 newMove = GetMoveAsVector(ax, val, true);
                // Only consider horizontal movement
                newMove.y = 0.0f;

                // If our current move isn't a jump and we were previously moving
                if (newMove != Vector3.zero && _prevMove != Vector3.zero)
                {
                    float dotAmt = Vector3.Dot(newMove.normalized, _prevMove.normalized);
                    if (dotAmt < DOT_THRESHOLD)
                    {
                        // Debug.Log("DOT_THRESHOLD reached: " + dotAmt);
                        Speed = 0.0f;
                    }
                }

                _move += newMove;
            }
        }
コード例 #3
0
ファイル: FreeLookPlayer.cs プロジェクト: BenjaBobs/Hubris
 public override void Move(InputManager.Axis ax, float val)
 {
     if (Active)
     {
         _move = GetMoveAsVector(ax, val, true);
     }
 }
コード例 #4
0
 // Basic Movement
 public override void Move(InputManager.Axis ax, float val)
 {
     if (Active)
     {
         _gObj.transform.Translate(GetMoveAsVector(ax, val * Speed, true), Space.World);
         // PhysForce(_move * _speed);
     }
 }
コード例 #5
0
        /// <summary>
        /// Returns a normalized direction vector along the specified axis. Can be relative to current rotation.
        /// </summary>
        public Vector3 GetMoveAsVector(InputManager.Axis ax, float val, bool relative = false)
        {
            Vector3 dir = Vector3.zero;

            if (!relative)
            {
                if (ax == InputManager.Axis.X)
                {
                    dir = new Vector3(val, 0, 0);
                }
                else if (ax == InputManager.Axis.Y)
                {
                    dir = new Vector3(0, val, 0);
                }
                else if (ax == InputManager.Axis.Z)
                {
                    dir = new Vector3(0, 0, val);
                }
                else
                {
                    if (HubrisCore.Instance.Debug)
                    {
                        LocalConsole.Instance.LogError("InputManager GetMoveAsVector(): Invalid Axis Vector requested", true);
                    }
                }
            }
            else
            {
                if (ax == InputManager.Axis.X)
                {
                    dir = _gObj.transform.right * val;
                }
                else if (ax == InputManager.Axis.Y)
                {
                    dir = _gObj.transform.up * val;
                }
                else if (ax == InputManager.Axis.Z)
                {
                    dir = _gObj.transform.forward * val;
                }
                else
                {
                    if (HubrisCore.Instance.Debug)
                    {
                        LocalConsole.Instance.LogError("InputManager GetMoveAsVector(): Invalid Axis Vector requested", true);
                    }
                }
            }

            return(dir.normalized);
        }
コード例 #6
0
    public void LookRotationSingleAxis(InputManager.Axis ax, Transform character, Transform camera)
    {
        float yRot;
        float xRot;

        if (ax == InputManager.Axis.X)
        {
            yRot = Input.GetAxis("Mouse X") * XSens;
            xRot = 0.0f;
        }
        else if (ax == InputManager.Axis.Y)
        {
            xRot = Input.GetAxis("Mouse Y") * YSens;
            yRot = 0.0f;
        }
        else
        {
            xRot = 0.0f;
            yRot = 0.0f;
        }

        m_CharacterTargetRot *= Quaternion.Euler(0f, yRot, 0f);
        m_CameraTargetRot    *= Quaternion.Euler(-xRot, 0f, 0f);

        if (clampVerticalRotation)
        {
            m_CameraTargetRot = ClampRotationAroundXAxis(m_CameraTargetRot);
        }

        if (smooth)
        {
            character.localRotation = Quaternion.Slerp(character.localRotation, m_CharacterTargetRot,
                                                       smoothTime * Time.deltaTime);
            camera.localRotation = Quaternion.Slerp(camera.localRotation, m_CameraTargetRot,
                                                    smoothTime * Time.deltaTime);
        }
        else
        {
            character.localRotation = m_CharacterTargetRot;
            camera.localRotation    = m_CameraTargetRot;
        }
    }
コード例 #7
0
        public override void SpecMove(SpecMoveType nType, InputManager.Axis ax, float val)
        {
            switch (nType)
            {
            case SpecMoveType.JUMP:
                if (_slopeChk >= _pCon.slopeLimit)
                {
                    return;
                }

                if (IsGrounded)
                {
                    SpeedTarget = CheckSpeedTarget();
                    _jumping    = true;
                    Move(ax, val);
                }
                break;

            default:                        // Default to regular move
                Move(ax, val);
                break;
            }
        }
コード例 #8
0
        private static InputManager.Axis[] GetAxisFromMap(Axis axis)
        {
            InputManager.Axis[] axes = new InputManager.Axis[2];

            switch (axis)
            {
            case Axis.Dpad:
                axes[0] = InputManager.Axis.DpadHorizontal;
                axes[1] = InputManager.Axis.DpadVertical;
                break;

            case Axis.LeftStick:
                axes[0] = InputManager.Axis.LsHorizontal;
                axes[1] = InputManager.Axis.LsVertical;
                break;

            case Axis.RightStick:
                axes[0] = InputManager.Axis.RsHorizontal;
                axes[1] = InputManager.Axis.RsVertical;
                break;
            }

            return(axes);
        }
コード例 #9
0
 // Movement with additional criteria or effects
 public override void SpecMove(SpecMoveType nType, InputManager.Axis ax, float val)
 {
     // Implement here
 }
コード例 #10
0
 public abstract void Rotate(InputManager.Axis ax, float val);
コード例 #11
0
 public abstract void SpecMove(SpecMoveType nType, InputManager.Axis ax, float val);
コード例 #12
0
 public abstract void Move(InputManager.Axis ax, float val);