72 if (!editorOpen && inputManager.IsMousePositionChanged())
74 const auto &oldPos = inputManager.GetMousePositionOld();
75 const auto ¤tPos = inputManager.GetMousePositionCurrent();
77 f32 deltaX = currentPos.x - oldPos.x;
78 f32 deltaY = currentPos.y - oldPos.y;
80 f32 yDeltaAngle = -deltaX * m_sensitivity * deltaTime;
81 m_yRot += yDeltaAngle;
82 glm::quat yRot = glm::angleAxis(glm::radians(m_yRot), glm::vec3(0, 1, 0));
84 f32 xDeltaAngle = -deltaY * m_sensitivity * deltaTime;
85 m_xRot += xDeltaAngle;
87 glm::quat xRot = glm::angleAxis(glm::radians(m_xRot), glm::vec3(1, 0, 0));
89 rotation = glm::normalize(yRot * xRot);
95 m_velocity =
vec3(0.0F);
96 m_kinematicController->Walk(
vec3(0.0F));
102 vec3 front = glm::normalize(FlattenY(rotation *
vec3(0.0F, 0.0F, -1.0F)));
103 vec3 right = glm::normalize(FlattenY(rotation *
vec3(1.0F, 0.0F, 0.0F)));
106 if (inputManager.IsKeyPressed(
Key::A))
109 }
else if (inputManager.IsKeyPressed(
Key::D))
113 if (inputManager.IsKeyPressed(
Key::W))
116 }
else if (inputManager.IsKeyPressed(
Key::S))
122 f32 wishMag = glm::length(wish);
123 if (wishMag > kMinHorizontalSpeed)
125 wishDir = wish / wishMag;
128 const bool onGround = m_kinematicController->OnGround();
129 const bool jumpPressed = inputManager.IsKeyPressed(
Key::Space);
133 ApplyFriction(deltaTime);
134 Accelerate(wishDir, m_moveSpeed, m_groundAccel, deltaTime);
139 f32 airWishSpeed = std::min(m_moveSpeed, m_airCap);
140 Accelerate(wishDir, airWishSpeed, m_airAccel, deltaTime);
144 m_kinematicController->Walk(
vec3(m_velocity.x * deltaTime, 0.0F, m_velocity.z * deltaTime));
148 if (onGround && jumpPressed && (m_autoHop || !m_jumpHeldLast))
150 m_kinematicController->Jump(
vec3(0.0F, m_moveSpeed * m_jumpSpeed, 0.0F));
152 m_jumpHeldLast = jumpPressed;