pub struct Player {
pub speed: f32,
pub sensitivity: f32,
pub roll_speed: f32,
pub velocity: Vec3,
pub mode: PlayerMode,
pub vertical_velocity: f32,
pub on_ground: bool,
pub sprinting: bool,
pub crouching: bool,
pub snap_roll_duration: f32,
pub snap_roll_easing: SnapRollEasing,
pub anchor_up: Vec3,
/* private fields */
}Expand description
State component that marks the player camera entity.
Attach this alongside Camera3d on a single entity. The camera entity
IS the player — there is no separate logical-player / camera hierarchy.
All player systems query for this component to locate the controlled entity.
Prefer constructing through PlayerConfig via spawn_player rather
than inserting Player directly, which also sets the initial transform and
projection from the resource.
§Default values
| Field | Default |
|---|---|
speed | 4.0 |
sensitivity | 1.0 |
roll_speed | 1.5 |
velocity | ZERO |
Fields§
§speed: f32Maximum flight speed in world units per second. Clamped implicitly by the lerp target: actual speed never exceeds this value regardless of frame rate.
sensitivity: f32Mouse sensitivity multiplier (dimensionless). 1.0 matches the default
“Minecraft-like” feel via the internal MOUSE_SCALE constant; lower
values are slower, higher values are faster. The Settings slider exposes
the range 0.10–1.00 (10%–100%) to the user.
roll_speed: f32Roll angular speed in radians per second applied while Q (roll left) or E (roll right) is held.
velocity: Vec3Current world-space velocity in world units per second. Smoothed each
frame by player_move using an exponential lerp; do not set this
directly unless you want to override the current momentum.
mode: PlayerModeMovement mode, copied from PlayerConfig::mode on spawn.
Determines which branch of player_look, player_move, and
player_resolve_collision is executed each frame.
vertical_velocity: f32Vertical velocity used in PlayerMode::Grounded mode.
Gravity accumulates here each frame; a jump impulse sets it to
PlayerMode::Grounded::jump_speed. Reset to 0.0 when the player
lands (collision pushes upward). Unused in PlayerMode::FreeFlightSixDof.
on_ground: boolWhether the player was on solid ground at the end of the last frame.
Set to true by player_resolve_collision when a voxel collision
produces an upward push; cleared to false at the start of each
collision pass. Gating jumps on this flag prevents infinite jumping.
Unused in PlayerMode::FreeFlightSixDof.
sprinting: boolWhether the player is currently sprinting.
true when Shift is held in PlayerMode::Grounded with
Player::on_ground true, and Player::crouching is false.
Crouch takes priority: if both are held this is false.
Always false in PlayerMode::FreeFlightSixDof.
crouching: boolWhether the player is currently crouching.
true when Ctrl is held in PlayerMode::Grounded mode.
Reduces the effective capsule half-height to CROUCH_HALF_HEIGHT
and movement speed to 40% of base speed.
Always false in PlayerMode::FreeFlightSixDof.
snap_roll_duration: f32Duration in seconds for a single snap-roll step animation (one hop to
the next world-aligned up candidate).
Only used when roll_mode == RollMode::Snap. Default: 0.5.
snap_roll_easing: SnapRollEasingEasing curve for snap-roll animations.
Only used when roll_mode == RollMode::Snap.
anchor_up: Vec3Current anchor axis for PlayerMode::FreeFlightAnchored look: always one of the
6 signed world axes. Yaw orbits this axis; pitch is clamped to ±89°
from the plane perpendicular to it. Initialized on spawn to the signed
world axis nearest the spawn orientation’s up. Unused in
PlayerMode::FreeFlightSixDof.
Trait Implementations§
Source§impl Component for Player
impl Component for Player
Source§const STORAGE_TYPE: StorageType = ::bevy::ecs::component::StorageType::Table
const STORAGE_TYPE: StorageType = ::bevy::ecs::component::StorageType::Table
Source§type Mutability = Mutable
type Mutability = Mutable
Component<Mutability = Mutable>,
while immutable components will instead have Component<Mutability = Immutable>. Read moreSource§fn register_required_components(
_requiree: ComponentId,
required_components: &mut RequiredComponentsRegistrator<'_, '_>,
)
fn register_required_components( _requiree: ComponentId, required_components: &mut RequiredComponentsRegistrator<'_, '_>, )
Source§fn clone_behavior() -> ComponentCloneBehavior
fn clone_behavior() -> ComponentCloneBehavior
Source§fn relationship_accessor() -> Option<ComponentRelationshipAccessor<Self>>
fn relationship_accessor() -> Option<ComponentRelationshipAccessor<Self>>
ComponentRelationshipAccessor required for working with relationships in dynamic contexts. Read moreSource§fn on_add() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
fn on_add() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
Source§fn on_insert() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
fn on_insert() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
Source§fn on_replace() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
fn on_replace() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
Source§fn on_remove() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
fn on_remove() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
Source§fn on_despawn() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
fn on_despawn() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
Source§fn map_entities<E>(_this: &mut Self, _mapper: &mut E)where
E: EntityMapper,
fn map_entities<E>(_this: &mut Self, _mapper: &mut E)where
E: EntityMapper,
EntityMapper. This is used to remap entities in contexts like scenes and entity cloning.
When deriving Component, this is populated by annotating fields containing entities with #[entities] Read moreAuto Trait Implementations§
impl Freeze for Player
impl RefUnwindSafe for Player
impl Send for Player
impl Sync for Player
impl Unpin for Player
impl UnsafeUnpin for Player
impl UnwindSafe for Player
Blanket Implementations§
Source§impl<T, U> AsBindGroupShaderType<U> for T
impl<T, U> AsBindGroupShaderType<U> for T
Source§fn as_bind_group_shader_type(&self, _images: &RenderAssets<GpuImage>) -> U
fn as_bind_group_shader_type(&self, _images: &RenderAssets<GpuImage>) -> U
T ShaderType for self. When used in AsBindGroup
derives, it is safe to assume that all images in self exist.Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<C> Bundle for Cwhere
C: Component,
impl<C> Bundle for Cwhere
C: Component,
fn component_ids( components: &mut ComponentsRegistrator<'_>, ) -> impl Iterator<Item = ComponentId> + use<C>
Source§fn get_component_ids(
components: &Components,
) -> impl Iterator<Item = Option<ComponentId>>
fn get_component_ids( components: &Components, ) -> impl Iterator<Item = Option<ComponentId>>
Source§impl<C> BundleFromComponents for Cwhere
C: Component,
impl<C> BundleFromComponents for Cwhere
C: Component,
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> ConditionalSend for Twhere
T: Send,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSend for T
impl<T> DowncastSend for T
impl<S, T> Duplex<S> for Twhere
T: FromSample<S> + ToSample<S>,
Source§impl<C> DynamicBundle for Cwhere
C: Component,
impl<C> DynamicBundle for Cwhere
C: Component,
Source§unsafe fn get_components(
ptr: MovingPtr<'_, C>,
func: &mut impl FnMut(StorageType, OwningPtr<'_>),
) -> <C as DynamicBundle>::Effect
unsafe fn get_components( ptr: MovingPtr<'_, C>, func: &mut impl FnMut(StorageType, OwningPtr<'_>), ) -> <C as DynamicBundle>::Effect
Source§unsafe fn apply_effect(
_ptr: MovingPtr<'_, MaybeUninit<C>>,
_entity: &mut EntityWorldMut<'_>,
)
unsafe fn apply_effect( _ptr: MovingPtr<'_, MaybeUninit<C>>, _entity: &mut EntityWorldMut<'_>, )
Source§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
Source§impl<T> FromWorld for Twhere
T: Default,
impl<T> FromWorld for Twhere
T: Default,
Source§fn from_world(_world: &mut World) -> T
fn from_world(_world: &mut World) -> T
Creates Self using default().
Source§impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
Source§impl<T> Identity for Twhere
T: ?Sized,
impl<T> Identity for Twhere
T: ?Sized,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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