Files
Nuake-custom/Nuake/Source/Nuake/Physics/CharacterController.h
2025-01-30 22:41:17 -05:00

62 lines
1.1 KiB
C++

#pragma once
#include "Nuake/Core/Core.h"
#include "Nuake/Core/Maths.h"
#include "Nuake/Physics/PhysicsShapes.h"
#include "Nuake/Scene/Entities/Entity.h"
namespace Nuake
{
class Entity;
namespace Physics
{
struct CharacterControllerSettings
{
Ref<Physics::PhysicShape> Shape;
float Friction;
float MaxSlopeAngle;
bool AutoStepping;
Vector3 StepDown;
Vector3 StepDownExtra;
Vector3 StepUp;
float StepMinDistance;
float StepDistance;
};
class CharacterController
{
public:
Entity Owner;
// Settings
Ref<PhysicShape> Shape;
float Friction = 0.5f;
float MaxSlopeAngle = 45.0f;
bool AutoStepping;
Vector3 StepDown;
Vector3 StepDownExtra;
Vector3 StepUp;
float StepDistance;
float StepMinDistance;
// State
Vector3 Position = Vector3(0, 0, 0);
Quat Rotation = Quat(1, 0, 0, 0);
bool IsOnGround = false;
public:
CharacterController(const CharacterControllerSettings& settings);
void MoveAndSlide(const Vector3& velocity);
void SetEntity(Entity& ent);
Entity GetEntity() const;
bool IsOnFloor() const
{
return IsOnGround;
}
};
}
}