feat: add moving platform support + fix jolt
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
#ifndef LIGHTKEEPER_FIRSTPERSONCONTROLLER_H
|
||||
#define LIGHTKEEPER_FIRSTPERSONCONTROLLER_H
|
||||
|
||||
#include <optional>
|
||||
|
||||
#include <glm/glm.hpp>
|
||||
#include <destrum/Input/InputManager.h>
|
||||
#include <destrum/ObjectModel/Component.h>
|
||||
@@ -45,7 +47,12 @@ public:
|
||||
void SetPossessed(bool possessed);
|
||||
|
||||
private:
|
||||
[[nodiscard]] bool CheckGrounded() const;
|
||||
struct GroundContact {
|
||||
glm::vec3 normal;
|
||||
glm::vec3 velocity;
|
||||
};
|
||||
|
||||
[[nodiscard]] std::optional<GroundContact> FindGround() const;
|
||||
[[nodiscard]] glm::vec3 GetWishDirection() const;
|
||||
[[nodiscard]] Interactable* FindFocusedInteractable() const;
|
||||
|
||||
@@ -67,11 +74,14 @@ private:
|
||||
float m_CoyoteTime{0.1f};
|
||||
float m_JumpBufferTime{0.12f};
|
||||
float m_InteractDistance{3.0f};
|
||||
float m_MaxSlopeAngle{glm::radians(50.0f)};
|
||||
float m_GroundStickSpeed{2.0f};
|
||||
|
||||
Interactable* m_FocusedInteractable{nullptr};
|
||||
|
||||
bool m_Possessed{false};
|
||||
bool m_Grounded{false};
|
||||
glm::vec3 m_GroundNormal{0.0f, 1.0f, 0.0f};
|
||||
bool m_JumpHeld{false};
|
||||
float m_CoyoteTimer{0.0f};
|
||||
float m_JumpBufferTimer{0.0f};
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include <components/FirstPersonController.h>
|
||||
#include <components/InteractableButton.h>
|
||||
#include <components/LightToggle.h>
|
||||
#include <components/MovingPlatform.h>
|
||||
#include <components/PrintComponent.h>
|
||||
#include <components/TriggerLoggerComponent.h>
|
||||
|
||||
@@ -13,6 +14,7 @@
|
||||
X(FirstPersonController) \
|
||||
X(InteractableButton) \
|
||||
X(LightToggle) \
|
||||
X(MovingPlatform) \
|
||||
X(PrintComponent) \
|
||||
X(TriggerLoggerComponent)
|
||||
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
#ifndef LIGHTKEEPER_MOVINGPLATFORM_H
|
||||
#define LIGHTKEEPER_MOVINGPLATFORM_H
|
||||
|
||||
#include <destrum/ObjectModel/Component.h>
|
||||
|
||||
#include <glm/vec3.hpp>
|
||||
|
||||
class MovingPlatform final : public Component {
|
||||
public:
|
||||
explicit MovingPlatform(GameObject& parent);
|
||||
|
||||
std::string GetTypeName() const override { return "MovingPlatform"; }
|
||||
|
||||
void Start() override;
|
||||
void Update(float dt) override;
|
||||
|
||||
nlohmann::json Serialize() const override;
|
||||
void Deserialize(const nlohmann::json& data) override;
|
||||
void ImGuiInspector() override;
|
||||
|
||||
void SetTravelOffset(const glm::vec3& offset) { m_TravelOffset = offset; }
|
||||
void SetTravelDuration(float seconds) { m_TravelDuration = seconds; }
|
||||
void SetPauseDuration(float seconds) { m_PauseDuration = seconds; }
|
||||
|
||||
private:
|
||||
[[nodiscard]] float GetTravelProgress() const;
|
||||
[[nodiscard]] glm::vec3 GetOffsetAt(float progress) const;
|
||||
|
||||
glm::vec3 m_TravelOffset{8.0f, 0.0f, 0.0f};
|
||||
float m_TravelDuration{4.0f};
|
||||
float m_PauseDuration{1.0f};
|
||||
|
||||
float m_ElapsedTime{0.0f};
|
||||
glm::vec3 m_StartPosition{0.0f};
|
||||
bool m_Started{false};
|
||||
};
|
||||
|
||||
#endif // LIGHTKEEPER_MOVINGPLATFORM_H
|
||||
Reference in New Issue
Block a user