CharacterController
- Module
- Physics
- Header
#include "Physics/CharacterController.h"- Namespace
Mowo
Constructors
| Signature | Name | Description |
|---|---|---|
CharacterController() | CharacterController | |
~CharacterController() | ~CharacterController | |
CharacterController(const CharacterController&) = delete | CharacterController |
Public functions
| Returns | Name | Description |
|---|---|---|
CharacterController& | operator= | |
void | Initialize | |
void | Shutdown | |
void | Update | |
Vec3 | GetPosition | |
void | SetPosition | |
bool | IsGrounded | |
Vec3 | GetGroundNormal | |
Vec3 | GetLinearVelocity | The character's OWN velocity. |
Vec3 | GetGroundVelocity | Velocity of whatever the character last stood on at the contact point, zero while airborne or on static ground. |
FPhysicsBodyId | GetGroundBodyID | |
ESurfaceType | GetGroundSurface | Surface under the feet, taken from the ground contact Jolt already tracks — no extra downward ray needed. |
bool | SetCrouched | Swap the capsule between standing and crouched height. |
bool | IsCrouched | |
float | GetShapeHeight | Total capsule height currently applied (crouch shrinks it). |
FPhysicsBodyId | GetInnerBodyID | The kinematic body that gives the capsule presence in the broad phase. |
void | SetInnerBodyEnabled | Take the inner body out of / back into the simulation. |
void | SetPushFlags | Live push gating, so the details panel's flags take effect without rebuilding the controller. |
void | ApplyTuning | Live stair, slope, strength and character-collision settings, so the details panel edits take effect without rebuilding the controller. |
uint32_t& | EntitySlotHint | The owning entity's ECS slot, cached for PhysicsSystem's per-frame controller loops (World::GetComponentsHinted refreshes it in place). |
Function details
CharacterController
CharacterController()~CharacterController
~CharacterController()CharacterController
CharacterController(const CharacterController&) = deleteoperator=
CharacterController& operator=(const CharacterController&) = deleteInitialize
void Initialize(PhysicsWorld* world, CharacterControllerComponent& component, Vec3 position)Shutdown
void Shutdown()Update
void Update(float dt, Vec3 desiredVelocity, Vec3 gravity)GetPosition
Vec3 GetPosition() constSetPosition
void SetPosition(Vec3 position)IsGrounded
bool IsGrounded() constGetGroundNormal
Vec3 GetGroundNormal() constGetLinearVelocity
Vec3 GetLinearVelocity() constThe character's OWN velocity. While grounded on a moving body the ground's velocity at the contact (linear plus angular about it) is added underneath for the step and the same share subtracted again here, so gameplay reasons about walking speed relative to the platform; the moment the feet leave it — a jump, the edge — the last ground velocity stays folded in and the reported value becomes the world velocity the character is carrying, and a landing re-bases that world velocity on the new ground.
GetGroundVelocity
Vec3 GetGroundVelocity() constVelocity of whatever the character last stood on at the contact point, zero while airborne or on static ground.
GetGroundBodyID
FPhysicsBodyId GetGroundBodyID() constGetGroundSurface
ESurfaceType GetGroundSurface() constSurface under the feet, taken from the ground contact Jolt already tracks — no extra downward ray needed.
SetCrouched
bool SetCrouched(bool crouched, float heightScale)Swap the capsule between standing and crouched height. Standing up is refused (stays crouched) while an obstruction above would penetrate the taller shape, and a changed heightScale re-shapes an already-crouched capsule the same way. Returns the ACTUAL crouch state after the attempt.
IsCrouched
bool IsCrouched() constGetShapeHeight
float GetShapeHeight() constTotal capsule height currently applied (crouch shrinks it).
GetInnerBodyID
FPhysicsBodyId GetInnerBodyID() constThe kinematic body that gives the capsule presence in the broad phase. Invalid when the component asked for no physical presence. PhysicsSystem maps it back to the owning entity so a trace that strikes a character resolves to an actor.
SetInnerBodyEnabled
void SetInnerBodyEnabled(bool enabled)Take the inner body out of / back into the simulation. A removed body stops answering traces and contacts entirely — a disabled character must not stay a wall. The BodyID (and its shape) survive.
SetPushFlags
void SetPushFlags(bool pushBodies, bool pushable)Live push gating, so the details panel's flags take effect without rebuilding the controller.
ApplyTuning
void ApplyTuning(const CharacterControllerComponent& component)Live stair, slope, strength and character-collision settings, so the details panel edits take effect without rebuilding the controller.
EntitySlotHint
uint32_t& EntitySlotHint()The owning entity's ECS slot, cached for PhysicsSystem's per-frame controller loops (World::GetComponentsHinted refreshes it in place).