feat: add firstpersoncontroller
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
#ifndef LIGHTKEEPER_FIRSTPERSONCONTROLLER_H
|
||||
#define LIGHTKEEPER_FIRSTPERSONCONTROLLER_H
|
||||
|
||||
#include <glm/glm.hpp>
|
||||
#include <destrum/Input/InputManager.h>
|
||||
#include <destrum/ObjectModel/Component.h>
|
||||
|
||||
class Rigidbody;
|
||||
class CapsuleCollider;
|
||||
|
||||
class FirstPersonController final : public Component {
|
||||
public:
|
||||
explicit FirstPersonController(GameObject& parent);
|
||||
|
||||
std::string GetTypeName() const override { return "FirstPersonController"; }
|
||||
|
||||
void Start() override;
|
||||
void Update(float dt) override;
|
||||
void FixedUpdate(float fixedDt) override;
|
||||
void ImGuiInspector() override;
|
||||
nlohmann::json Serialize() const override;
|
||||
void Deserialize(const nlohmann::json& data) override;
|
||||
|
||||
[[nodiscard]] float GetYaw() const { return m_Yaw; }
|
||||
[[nodiscard]] float GetPitch() const { return m_Pitch; }
|
||||
[[nodiscard]] float GetEyeHeight() const { return m_EyeHeight; }
|
||||
|
||||
void SetMovementSpeed(float speed) { m_MovementSpeed = speed; }
|
||||
[[nodiscard]] float GetMovementSpeed() const { return m_MovementSpeed; }
|
||||
|
||||
void SetMouseSensitivity(float sens) { m_MouseSensitivity = sens; }
|
||||
[[nodiscard]] float GetMouseSensitivity() const { return m_MouseSensitivity; }
|
||||
|
||||
[[nodiscard]] bool IsMouseCaptured() const { return InputManager::GetInstance().IsMouseCaptured(); }
|
||||
void SetMouseCaptured(bool captured);
|
||||
|
||||
private:
|
||||
Rigidbody* m_Rigidbody{nullptr};
|
||||
CapsuleCollider* m_Capsule{nullptr};
|
||||
|
||||
float m_Yaw{0.0f};
|
||||
float m_Pitch{0.0f};
|
||||
float m_MovementSpeed{5.0f};
|
||||
float m_MouseSensitivity{0.002f};
|
||||
float m_EyeHeight{1.6f};
|
||||
};
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user