void ReadStates() { CustomInput customInput = CustomInput.Instance; this.ReadCameraInput(); m_ped.MouseScrollInput = Input.mouseScrollDelta; m_ped.IsAimOn = customInput.GetButton("RightClick"); m_ped.IsFireOn = customInput.GetButton("LeftClick"); m_ped.IsJumpOn = customInput.GetButton("Jump"); Vector3 inputMove = Vector3.zero; if (m_smoothMovement) { inputMove = new Vector3(customInput.GetAxis("Horizontal"), 0f, customInput.GetAxis("Vertical")); } else { inputMove = new Vector3(customInput.GetAxisRaw("Horizontal"), 0f, customInput.GetAxisRaw("Vertical")); } if (inputMove.sqrMagnitude > 0f) { inputMove.Normalize(); if (customInput.GetButton("Walk")) { m_ped.IsWalkOn = true; } else if (customInput.GetButton("Sprint")) { m_ped.IsSprintOn = true; } else { m_ped.IsRunOn = true; } } if (m_ped.Camera != null) { m_ped.Movement = m_ped.Camera.transform.TransformVector(inputMove).normalized; } else { m_ped.Movement = inputMove.normalized; } if (m_ped.Movement.sqrMagnitude > float.Epsilon) { // only assign heading if there is any movement - we don't want the heading to be zero vector m_ped.Heading = m_ped.Movement; } }
private void ReadCameraInput() { CustomInput customInput = CustomInput.Instance; if (GameManager.CanPlayerReadInput()) { // rotate camera // FIXME: Camera rotation should be done by ped's current state. We should only assign mouse move input. var mouseDelta = new Vector2(customInput.GetAxisRaw("Mouse X"), customInput.GetAxisRaw("Mouse Y")); var rightAnalogDelta = new Vector2(customInput.GetAxisRaw("Joystick X"), customInput.GetAxisRaw("Joystick Y")); Vector2 totalMouseDelta = mouseDelta + rightAnalogDelta; totalMouseDelta = Vector2.Scale(totalMouseDelta, GameManager.Instance.cursorSensitivity); m_ped.MouseMoveInput = totalMouseDelta; if (m_doSmooth) { _smoothMouse.x = Mathf.Lerp(_smoothMouse.x, totalMouseDelta.x, 1f / smoothing.x); _smoothMouse.y = Mathf.Lerp(_smoothMouse.y, totalMouseDelta.y, 1f / smoothing.y); _mouseAbsolute += _smoothMouse; } else { _mouseAbsolute += totalMouseDelta; } if (clampInDegrees.y > 0) { _mouseAbsolute.y = Mathf.Clamp(_mouseAbsolute.y, -clampInDegrees.y, clampInDegrees.y); } } }
float GetAxisRaw(int axis) { return(CustomInput.GetAxisRaw(axis)); }