pub struct Physics {Show 17 fields
pub velocity: Vec3,
pub vec_delta_codec: VecDeltaCodec,
pub old_position: Vec3,
pub x_acceleration: f32,
pub y_acceleration: f32,
pub z_acceleration: f32,
pub no_jump_delay: u32,
pub dimensions: EntityDimensions,
pub bounding_box: AABB,
pub has_impulse: bool,
pub horizontal_collision: bool,
pub vertical_collision: bool,
pub water_fluid_height: f64,
pub lava_fluid_height: f64,
pub was_touching_water: bool,
pub fall_distance: f32,
pub remaining_fire_ticks: i32,
/* private fields */
}
Expand description
The physics data relating to the entity, such as position, velocity, and bounding box.
Fields§
§velocity: Vec3
How fast the entity is moving.
Sometimes referred to as the delta movement.
vec_delta_codec: VecDeltaCodec
§old_position: Vec3
The position of the entity before it moved this tick.
This is set immediately before physics is done.
x_acceleration: f32
The acceleration here is the force that will be attempted to be added to the entity’s velocity next tick.
You should typically not set this yourself, since it’s controlled by how the entity is trying to move.
y_acceleration: f32
§z_acceleration: f32
§no_jump_delay: u32
The number of ticks until we jump again, if the jump key is being held.
This must be 0 for us to be able to jump. Sets to 10 when we do a jump and sets to 0 if we’re not trying to jump.
dimensions: EntityDimensions
The width and height of the entity.
bounding_box: AABB
The bounding box of the entity. This is more than just width and height, unlike dimensions.
has_impulse: bool
§horizontal_collision: bool
§vertical_collision: bool
§water_fluid_height: f64
§lava_fluid_height: f64
§was_touching_water: bool
§fall_distance: f32
§remaining_fire_ticks: i32
Implementations§
Source§impl Physics
impl Physics
pub fn new(dimensions: EntityDimensions, pos: Vec3) -> Self
pub fn on_ground(&self) -> bool
Sourcepub fn set_on_ground(&mut self, on_ground: bool)
pub fn set_on_ground(&mut self, on_ground: bool)
Updates Self::on_ground
and Self::last_on_ground
.
Sourcepub fn last_on_ground(&self) -> bool
pub fn last_on_ground(&self) -> bool
The last value of the on_ground value.
This is used by Azalea internally for physics, it might not work as you expect since it can be influenced by packets sent by the server.
pub fn set_last_on_ground(&mut self, last_on_ground: bool)
pub fn reset_fall_distance(&mut self)
pub fn clear_fire(&mut self)
pub fn is_in_water(&self) -> bool
pub fn is_in_lava(&self) -> bool
pub fn set_old_pos(&mut self, pos: &Position)
Trait Implementations§
Source§impl Component for Physics
impl Component for Physics
Source§const STORAGE_TYPE: StorageType = bevy_ecs::component::StorageType::Table
const STORAGE_TYPE: StorageType = bevy_ecs::component::StorageType::Table
Source§fn register_required_components(
requiree: ComponentId,
components: &mut Components,
storages: &mut Storages,
required_components: &mut RequiredComponents,
inheritance_depth: u16,
)
fn register_required_components( requiree: ComponentId, components: &mut Components, storages: &mut Storages, required_components: &mut RequiredComponents, inheritance_depth: u16, )
Source§fn register_component_hooks(hooks: &mut ComponentHooks)
fn register_component_hooks(hooks: &mut ComponentHooks)
ComponentHooks
].Auto Trait Implementations§
impl Freeze for Physics
impl RefUnwindSafe for Physics
impl Send for Physics
impl Sync for Physics
impl Unpin for Physics
impl UnwindSafe for Physics
Blanket Implementations§
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
§impl<C> Bundle for Cwhere
C: Component,
impl<C> Bundle for Cwhere
C: Component,
fn component_ids( components: &mut Components, storages: &mut Storages, ids: &mut impl FnMut(ComponentId), )
unsafe fn from_components<T, F>(ctx: &mut T, func: &mut F) -> C
§fn register_required_components(
components: &mut Components,
storages: &mut Storages,
required_components: &mut RequiredComponents,
)
fn register_required_components( components: &mut Components, storages: &mut Storages, required_components: &mut RequiredComponents, )
Bundle
].§fn get_component_ids(
components: &Components,
ids: &mut impl FnMut(Option<ComponentId>),
)
fn get_component_ids( components: &Components, ids: &mut impl FnMut(Option<ComponentId>), )
Bundle
]’s component ids. This will be None
if the component has not been registered.Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§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>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.§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>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.§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.§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.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<C> DynamicBundle for Cwhere
C: Component,
impl<C> DynamicBundle for Cwhere
C: Component,
fn get_components(self, func: &mut impl FnMut(StorageType, OwningPtr<'_>))
§impl<T> FromWorld for Twhere
T: Default,
impl<T> FromWorld for Twhere
T: Default,
§fn from_world(_world: &mut World) -> T
fn from_world(_world: &mut World) -> T
Creates Self
using default()
.