vkmEngine 1.0.0
A C++ game engine · vkmengine.com
Loading...
Searching...
No Matches
character_controller.h
1#pragma once
2
3#include <glm/glm.hpp>
4
5#include "core/reflect.h"
6
7namespace Vkm::Engine {
8
17 glm::vec3 moveInput = {0.0f, 0.0f, 0.0f};
18 bool jumpRequested = false;
19
20 float jumpSpeed = 5.0f;
21 float acceleration = 40.0f;
22 float airControl = 0.25f;
23 float maxSlopeAngle = 50.0f;
24
31 float stepHeight = 0.4f;
32
33 bool grounded = false;
34
35 // A climb outlives the condition that started it: it leaves the ground first, so re-deciding it
36 // from `grounded` each tick would abort it. These carry it to the measured height.
37 bool stepping = false;
38 float stepTargetY = 0.0f;
39 float stepTime = 0.0f;
40 glm::vec3 groundNormal = {0.0f, 1.0f, 0.0f};
41};
42
43} // namespace Vkm::Engine
44
45// Only the tuning is serialized; the rest is per-tick traffic.
47 VKM_F(jumpSpeed)
48 VKM_F(acceleration)
49 VKM_F(airControl)
50 VKM_F(maxSlopeAngle)
51 VKM_F(stepHeight)
52VKM_REFLECT_END()
Turns a desired direction into velocity on a Rigidbody, and reports what the body stands on.
Definition character_controller.h:16
float stepTargetY
Read-only: world Y the feet are climbing to.
Definition character_controller.h:38
glm::vec3 groundNormal
Read-only: its normal; world up when airborne.
Definition character_controller.h:40
float stepTime
Read-only: seconds the current climb has run.
Definition character_controller.h:39
float maxSlopeAngle
Degrees; a steeper surface holds nothing up.
Definition character_controller.h:23
float stepHeight
Tallest obstacle, in metres, the character mounts instead of stopping at; zero disables it.
Definition character_controller.h:31
float acceleration
How fast velocity closes on moveInput, m/s^2.
Definition character_controller.h:21
bool jumpRequested
Cleared each tick this end simulates, honoured or not.
Definition character_controller.h:18
glm::vec3 moveInput
Desired horizontal velocity, world space, m/s.
Definition character_controller.h:17
float jumpSpeed
Upward speed a jump starts at, m/s.
Definition character_controller.h:20
float airControl
Fraction of acceleration available while airborne.
Definition character_controller.h:22
bool grounded
Read-only: on a surface within maxSlopeAngle.
Definition character_controller.h:33
bool stepping
Read-only: mounting something this tick.
Definition character_controller.h:37