diff --git a/ECS/Components/MouseLook.h b/ECS/Components/MouseLook.h
index a60ed5c..ff9f27e 100644
--- a/ECS/Components/MouseLook.h
+++ b/ECS/Components/MouseLook.h
@@ -9,6 +9,10 @@ struct MouseLook {
explicit MouseLook(float sensitivity) : sensitivity(sensitivity) {}
float sensitivity;
+
+ double yaw = 0.0;
+
+ double pitch = 0.0;
};
#endif //ECSGAME_MOUSELOOK_H
diff --git a/ECS/Systems/KeyboardMovementSystem.h b/ECS/Systems/KeyboardMovementSystem.h
index 90a0917..729201d 100644
--- a/ECS/Systems/KeyboardMovementSystem.h
+++ b/ECS/Systems/KeyboardMovementSystem.h
@@ -58,7 +58,6 @@ class KeyboardMovementSystem : public EntitySystem, public EventSubscribersensitivity;
- pitch += yOffset * mouse->sensitivity;
+ mouse->yaw += xOffset * mouse->sensitivity;
+ mouse->pitch += yOffset * mouse->sensitivity;
});
}
void tick(World *pWorld, float deltaTime) override {
pWorld->each([&](Entity *ent, ComponentHandle transform, ComponentHandle mouse, ComponentHandle camera) {
- if(pitch > 89.0f)
- pitch = 89.0f;
- if(pitch < -89.0f)
- pitch = -89.0f;
+ if(mouse->pitch > 89.0f)
+ mouse->pitch = 89.0f;
+ if(mouse->pitch < -89.0f)
+ mouse->pitch = -89.0f;
glm::mat4x4 newTransform = glm::mat4x4(1.0);
- newTransform = glm::rotate(newTransform, glm::radians((float)pitch), transform->right());
- newTransform = glm::rotate(newTransform, glm::radians((float)yaw), glm::vec3(0.0, 1.0, 0.0));
+ newTransform = glm::rotate(newTransform, glm::radians((float)mouse->pitch), transform->right());
+ newTransform = glm::rotate(newTransform, glm::radians((float)mouse->yaw), glm::vec3(0.0, 1.0, 0.0));
newTransform[3] = transform->matrix[3];
@@ -61,9 +61,6 @@ private:
double lastX;
double lastY;
- double pitch = 0.0;
- double yaw = 0.0;
-
World *myWorld;
};