Enum bevy_retrograde_physics::RigidBody [−]
pub enum RigidBody { Dynamic, Static, KinematicPositionBased, KinematicVelocityBased, Sensor, }
Expand description
Component that mark the entity as being a rigid body
It’ll need some CollisionShape
to be attached. Either in the same entity or in a direct child
Example
fn spawn(mut commands: Commands, mut materials: ResMut<Assets<ColorMaterial>>) { commands.spawn_bundle(todo!("Spawn your sprite/mesh, incl. at least a GlobalTransform")) .insert(RigidBody::Dynamic) // Create a dynamic rigid body .insert(CollisionShape::Sphere { radius: 1.0 }); // Attach a collision shape }
Variants
A dynamic body is normally affected by physic forces and affect the other bodies normally too.
This is the most “natural” type in the sense that, in real life, everything is dynamic.
It is the default type.
A static body is not affected by physic forces and doesn’t move. But it does affect the other bodies.
This effectively behaves like a dynamic body with infinite mass and zero velocity.
It is well suited for terrain and static obstacles.
A kinematic body is not moved by the physics engine. But it can have user-defined position.
It affects the other bodies normally but is not affected by them.
If the transform is updated, then a velocity will be automatically calculated, producing realistic interaction with other bodies.
It is well-suited for moving platforms.
A kinematic body is not moved by the physics engine. But it can have user-defined velocity.
It affects the other bodies normally but is not affected by them.
If the velocity is updated, then a velocity will produce realistic interaction with other bodies.
It is well-suited for moving platforms.
A sensor is not affected by physics forces and doesn’t affect other bodies either.
Other bodies will be able to penetrate the sensor. But it still participates in collision events.
A sensor is useful when we are only interested in collision events. One may, for example, add a sensor to detect when the player reaches a certain area.
Implementations
impl RigidBody
impl RigidBody
pub fn can_have_velocity(self) -> bool
pub fn can_have_velocity(self) -> bool
Returns true if this body type can be moved by Velocity
Trait Implementations
impl GetTypeRegistration for RigidBody
impl GetTypeRegistration for RigidBody
pub fn get_type_registration() -> TypeRegistration
impl Reflect for RigidBody
impl Reflect for RigidBody
pub fn clone_value(&self) -> Box<dyn Reflect + 'static, Global>
pub fn apply(&mut self, value: &(dyn Reflect + 'static))
pub fn set(
&mut self,
value: Box<dyn Reflect + 'static, Global>
) -> Result<(), Box<dyn Reflect + 'static, Global>>
pub fn reflect_ref(&self) -> ReflectRef<'_>
pub fn reflect_mut(&mut self) -> ReflectMut<'_>
pub fn reflect_hash(&self) -> Option<u64>
pub fn reflect_hash(&self) -> Option<u64>
Returns a hash of the value (which includes the type) if hashing is supported. Otherwise
None
will be returned. Read more
pub fn reflect_partial_eq(
&self,
value: &(dyn Reflect + 'static)
) -> Option<bool>
pub fn reflect_partial_eq(
&self,
value: &(dyn Reflect + 'static)
) -> Option<bool>
Returns a “partial equal” comparison result if comparison is supported. Otherwise None
will be returned. Read more
pub fn serializable(&self) -> Option<Serializable<'_>>
pub fn serializable(&self) -> Option<Serializable<'_>>
Returns a serializable value, if serialization is supported. Otherwise None
will be
returned. Read more
impl StructuralEq for RigidBody
impl StructuralPartialEq for RigidBody
Auto Trait Implementations
impl RefUnwindSafe for RigidBody
impl UnwindSafe for RigidBody
Blanket Implementations
Mutably borrows from an owned value. Read more
impl<T> Downcast for T where
T: Any,
impl<T> Downcast for T where
T: Any,
Convert 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
. Read more
pub fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
pub fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
Convert Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
. Read more
Convert &Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s. Read more
pub fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
pub fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert &mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s. Read more
impl<T> FromWorld for T where
T: Default,
impl<T> FromWorld for T where
T: Default,
pub fn from_world(_world: &mut World) -> T
pub fn from_world(_world: &mut World) -> T
Creates Self
using data from the given [World]
Instruments this type with the provided Span
, returning an
Instrumented
wrapper. Read more
type Output = T
type Output = T
Should always be Self
The inverse inclusion map: attempts to construct self
from the equivalent element of its
superset. Read more
pub fn is_in_subset(&self) -> bool
pub fn is_in_subset(&self) -> bool
Checks if self
is actually part of its subset T
(and can be converted to it).
pub fn to_subset_unchecked(&self) -> SS
pub fn to_subset_unchecked(&self) -> SS
Use with care! Same as self.to_subset
but without any property checks. Always succeeds.
pub fn from_subset(element: &SS) -> SP
pub fn from_subset(element: &SS) -> SP
The inclusion map: converts self
to the equivalent element of its superset.
pub fn clone_type_data(&self) -> Box<dyn TypeData + 'static, Global>
pub fn vzip(self) -> V