pub struct CharacterController {
pub position: [f32; 3],
pub velocity: [f32; 3],
pub step_height: f32,
pub slope_limit_degrees: f32,
pub ground_snap_distance: f32,
pub is_grounded: bool,
pub radius: f32,
pub half_height: f32,
pub gravity: [f32; 3],
}Expand description
Character controller state.
Fields§
§position: [f32; 3]Current world-space position.
velocity: [f32; 3]Current velocity (m/s).
step_height: f32Maximum step-up height (m). The controller will automatically climb steps shorter than this.
slope_limit_degrees: f32Maximum slope angle (degrees) that the character can walk on.
ground_snap_distance: f32Snap distance for keeping the character grounded on slopes/stairs.
is_grounded: boolWhether the character is currently on the ground.
radius: f32Collision capsule radius.
half_height: f32Collision capsule half-height (from center to cap center).
gravity: [f32; 3]Gravity acceleration (m/s²).
Implementations§
Source§impl CharacterController
impl CharacterController
Sourcepub fn new(position: [f32; 3], radius: f32, height: f32) -> Self
pub fn new(position: [f32; 3], radius: f32, height: f32) -> Self
Create a character controller with a capsule collider.
Sourcepub fn collision_shape(&self) -> CollisionShape
pub fn collision_shape(&self) -> CollisionShape
The collision shape of the character.
Sourcepub fn move_and_slide(
&mut self,
desired_velocity: [f32; 3],
dt: f32,
world: &PhysicsWorld,
) -> [f32; 3]
pub fn move_and_slide( &mut self, desired_velocity: [f32; 3], dt: f32, world: &PhysicsWorld, ) -> [f32; 3]
Move the character using move-and-slide with step-up sweep and slope limiting.
desired_velocity: input movement velocity (horizontal only, Y ignored for movement).
dt: time step in seconds.
world: physics world for collision queries.
Returns the final position delta.