void FixedUpdate() { m_MouseLook.UpdateCursorLock(); }
// Update is called once per frame void FixedUpdate() { m_MouseLook.LookRotation(transform, m_Camera.transform); if (!m_PreviouslyGrounded && m_CharacterController.isGrounded) { m_MoveDir.y = 0f; m_Jumping = false; } if (!m_CharacterController.isGrounded && !m_Jumping && m_PreviouslyGrounded) { m_MoveDir.y = 0f; } //Debug.Log("m_PreviouslyGrounded = " + m_PreviouslyGrounded); //Debug.Log("m_CharacterController.isGrounded = " + m_CharacterController.isGrounded); m_PreviouslyGrounded = m_CharacterController.isGrounded; float h = InputManager.GetAxis("Horizontal"); float v = InputManager.GetAxis("Vertical"); m_Input = new Vector2(h, v); if (m_Input.sqrMagnitude > 1) { m_Input.Normalize(); } Vector3 desiredMove = transform.forward * m_Input.y + transform.right * m_Input.x; RaycastHit hitInfo; Physics.SphereCast(transform.position, m_CharacterController.radius, Vector3.down, out hitInfo, m_CharacterController.height / 2f, ~0, QueryTriggerInteraction.Ignore); desiredMove = Vector3.ProjectOnPlane(desiredMove, hitInfo.normal).normalized; m_MoveDir.x = desiredMove.x * speed; m_MoveDir.z = desiredMove.z * speed; //Debug.Log("m_Jump = " + m_Jump); //Debug.Log("m_Jumping = " + m_Jumping); if (InputManager.GetButtonDown("Jump")) { Debug.Log("11111111111111111111111111111111111111111111111111111111111111111111"); } if (!m_Jump && !m_Jumping) { m_Jump = InputManager.GetButtonDown("Jump"); } if (m_CharacterController.isGrounded) { m_MoveDir.y = -m_StickToGroundForce; if (m_Jump) { m_MoveDir.y = m_JumpSpeed; m_Jump = false; m_Jumping = true; } } else { m_MoveDir += Physics.gravity * m_GravityMultiplier * Time.fixedDeltaTime; } m_CharacterController.Move(m_MoveDir * Time.fixedDeltaTime); //UpdateMousePosition(); m_MouseLook.UpdateCursorLock(); }