Fixed followMouse bug layover from old origin point problem

This commit is contained in:
Ethan Adams 2025-03-01 13:05:30 -05:00
parent c6a21b24bb
commit 6691d670e2

View file

@ -130,7 +130,7 @@ void GameActor::cycleWeapons(const MouseState& mouse_state)
} }
void GameActor::followMouse(const MouseState& mouse_state) void GameActor::followMouse(const MouseState& mouse_state)
{ {
glm::vec2 direction = glm::vec2(mouse_state.x, mouse_state.y) - glm::vec2(localPosition.x + 0.5f * scale.x, localPosition.y + 0.5f * scale.y); glm::vec2 direction = glm::vec2(mouse_state.x, mouse_state.y) - glm::vec2(localPosition.x, localPosition.y);
float newRotation = glm::degrees(glm::atan(direction.y, direction.x)); float newRotation = glm::degrees(glm::atan(direction.y, direction.x));
if (getDirectionFromRotation(rotation) != getDirectionFromRotation(newRotation)) { if (getDirectionFromRotation(rotation) != getDirectionFromRotation(newRotation)) {
if (auto event = sceneContext->getEventManager().lock()) { if (auto event = sceneContext->getEventManager().lock()) {