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); } } } }
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; } }
public override void Move(InputManager.Axis ax, float val) { if (Active) { _move = GetMoveAsVector(ax, val, true); } }
// 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); } }
/// <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); }
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; } }
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; } }
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); }
// Movement with additional criteria or effects public override void SpecMove(SpecMoveType nType, InputManager.Axis ax, float val) { // Implement here }
public abstract void Rotate(InputManager.Axis ax, float val);
public abstract void SpecMove(SpecMoveType nType, InputManager.Axis ax, float val);
public abstract void Move(InputManager.Axis ax, float val);