Skip to main content

CharacterDef

Struct CharacterDef 

Source
pub struct CharacterDef {
Show 21 fields pub radius: f64, pub height: f64, pub eye_height: f64, pub gravity: f64, pub jump_speed: f64, pub max_fall_speed: f64, pub walk_speed: f64, pub accel_ground: f64, pub accel_air: f64, pub step_up: f64, pub coyote_time: f64, pub jump_buffer: f64, pub fly_speed: f64, pub fly_accel: f64, pub solidity: Solidity, pub buoyancy: f64, pub water_drag: f64, pub swim_speed: f64, pub swim_accel: f64, pub swim_enter_frac: f64, pub swim_exit_frac: f64,
}
Expand description

Construction-time parameters of a CharacterBody. Distances in voxels (= world units), times in seconds.

Fields§

§radius: f64

Half-extent of the collision box in x and y.

§height: f64

Feet → head extent. The body occupies z ∈ [feet.z - height, feet.z] (+z is down).

§eye_height: f64

Feet → eye distance for CharacterBody::eye_pos (the camera anchor), along the same up-is-−z axis.

§gravity: f64

Gravity acceleration, positive (+z is down).

§jump_speed: f64

Initial upward speed of a jump, applied as negative z velocity.

§max_fall_speed: f64

Terminal fall speed (+z velocity cap). Besides realism, this bounds the per-frame probe cost: substeps scale with displacement, so an unbounded fall gets linearly more expensive the longer it lasts (the CC.5 stress probe caught exactly that).

§walk_speed: f64

Target horizontal speed while walking.

§accel_ground: f64

How fast the horizontal velocity approaches the wish direction on the ground, in speed units per second. Also the stopping (friction) rate — with no input the target is zero.

§accel_air: f64

Same, airborne — low, so jumps keep their momentum but retain a little steering.

§step_up: f64

Auto-step height: a grounded body blocked horizontally climbs ledges up to this many voxels tall, if the lifted body fits and finds ground on the far side. 1.05 clears 1-voxel stairs; set 0.0 to disable.

§coyote_time: f64

Grace window after walking off an edge during which a jump still fires (seconds) — “coyote time”.

§jump_buffer: f64

How long a jump pressed in mid-air stays queued and fires on landing (seconds).

§fly_speed: f64

Target speed in MoveMode::Fly / MoveMode::Noclip, where the full 3D wish steers.

§fly_accel: f64

Acceleration toward the wish in the fly modes. The default f64::INFINITY means instant start/stop — a fly camera, not a body with inertia (the demos’ classic feel); set a finite rate for drifty flight.

§solidity: Solidity

What counts as solid (bedrock-placeholder policy — must match how the host renders the world; see Solidity::bedrock_blocks).

§buoyancy: f64

WT.1 — upward acceleration at FULL submersion, positive (applied toward −z, fighting gravity). With no stroke input the body settles where gravity == buoyancy · fraction; the defaults (24 / 32) float it at 75% submerged — head above the surface.

§water_drag: f64

WT.1 — vertical velocity damping in water, per second (exponential). Caps stroke/fall speeds under water and kills the surface bob; higher = thicker water.

§swim_speed: f64

WT.1 — target horizontal speed while swimming.

§swim_accel: f64

WT.1 — acceleration while swimming: the horizontal approach rate AND the vertical stroke strength (jump up / sink down).

§swim_enter_frac: f64

WT.1 — the swim state ENGAGES at this submerged fraction of the body height. The default 0.6 deliberately lets the default 1.8-body WADE through minimal authored water (one voxel over the floor = fraction ≈ 0.56): a decorative puddle must not swap walking for swimming.

§swim_exit_frac: f64

…and RELEASES below this one. The gap is deliberate hysteresis: a bobbing body at the waterline must not flicker between swimming and walking (enter > exit). The EFFECTIVE release threshold is additionally clamped below the no-stroke bobbing equilibrium (gravity / buoyancy) at runtime, so a very buoyant “cork” tuning can’t limit-cycle at the waterline.

Trait Implementations§

Source§

impl Clone for CharacterDef

Source§

fn clone(&self) -> CharacterDef

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for CharacterDef

Source§

impl Debug for CharacterDef

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for CharacterDef

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.