Struct heron_core::PhysicMaterial
source · Expand description
Component that defines the physics properties of the rigid body
It must be inserted on the same entity of a RigidBody
Example
fn spawn(mut commands: Commands) {
commands.spawn_bundle(todo!("Spawn your sprite/mesh, incl. at least a GlobalTransform"))
.insert(CollisionShape::Sphere { radius: 1.0 }) // Make a body (is dynamic by default)
.insert(PhysicMaterial {
restitution: 0.5, // Define the restitution. Higher value means more "bouncy"
density: 2.0, // Define the density. Higher value means heavier.
friction: 0.5, // Define the friction. Higher value means higher friction.
});
}
Fields
restitution: f32
Coefficient of restitution. Affect how much it “bounces” when colliding with other objects.
The higher the value, the more “bouncy”.
Typical values are between 0 (perfectly inelastic) and 1 (perfectly elastic)
density: f32
Density. It affects how much the body resists forces.
The higher the value, the heavier.
Value must be greater than 0. Except for sensor and static bodies, in which case the value is ignored.
friction: f32
Friction. It affects the relative motion of two bodies in contact.
The higher the value, the higher friction.
Typical values are between 0 (ideal) and 1 (max friction)
Implementations
sourceimpl PhysicMaterial
impl PhysicMaterial
sourcepub const PERFECTLY_INELASTIC_RESTITUTION: f32 = 0f32
pub const PERFECTLY_INELASTIC_RESTITUTION: f32 = 0f32
Perfectly inelastic restitution coefficient, all kinematic energy is lost on collision. (Do not bounce at all)
sourcepub const PERFECTLY_ELASTIC_RESTITUTION: f32 = 1f32
pub const PERFECTLY_ELASTIC_RESTITUTION: f32 = 1f32
Perfectly elastic restitution coefficient, all kinematic energy is restated in movement. (Very bouncy)
Trait Implementations
sourceimpl Clone for PhysicMaterial
impl Clone for PhysicMaterial
sourcefn clone(&self) -> PhysicMaterial
fn clone(&self) -> PhysicMaterial
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresourceimpl Component for PhysicMaterialwhere
Self: Send + Sync + 'static,
impl Component for PhysicMaterialwhere
Self: Send + Sync + 'static,
type Storage = TableStorage
sourceimpl Debug for PhysicMaterial
impl Debug for PhysicMaterial
sourceimpl Default for PhysicMaterial
impl Default for PhysicMaterial
sourceimpl GetTypeRegistration for PhysicMaterial
impl GetTypeRegistration for PhysicMaterial
fn get_type_registration() -> TypeRegistration
sourceimpl PartialEq<PhysicMaterial> for PhysicMaterial
impl PartialEq<PhysicMaterial> for PhysicMaterial
sourcefn eq(&self, other: &PhysicMaterial) -> bool
fn eq(&self, other: &PhysicMaterial) -> bool
sourceimpl Reflect for PhysicMaterial
impl Reflect for PhysicMaterial
sourcefn get_type_info(&self) -> &'static TypeInfo
fn get_type_info(&self) -> &'static TypeInfo
TypeInfo
] of the underlying type. Read moresourcefn as_any_mut(&mut self) -> &mut dyn Any
fn as_any_mut(&mut self) -> &mut dyn Any
&mut dyn Any
.sourcefn as_reflect(&self) -> &dyn Reflect
fn as_reflect(&self) -> &dyn Reflect
sourcefn as_reflect_mut(&mut self) -> &mut dyn Reflect
fn as_reflect_mut(&mut self) -> &mut dyn Reflect
sourcefn clone_value(&self) -> Box<dyn Reflect>
fn clone_value(&self) -> Box<dyn Reflect>
Reflect
trait object. Read moresourcefn set(&mut self, value: Box<dyn Reflect>) -> Result<(), Box<dyn Reflect>>
fn set(&mut self, value: Box<dyn Reflect>) -> Result<(), Box<dyn Reflect>>
sourcefn reflect_ref(&self) -> ReflectRef<'_>
fn reflect_ref(&self) -> ReflectRef<'_>
sourcefn reflect_mut(&mut self) -> ReflectMut<'_>
fn reflect_mut(&mut self) -> ReflectMut<'_>
sourcefn reflect_partial_eq(&self, value: &dyn Reflect) -> Option<bool>
fn reflect_partial_eq(&self, value: &dyn Reflect) -> Option<bool>
fn reflect_hash(&self) -> Option<u64>
fn reflect_hash(&self) -> Option<u64>
fn serializable(&self) -> Option<Serializable<'_>>
fn serializable(&self) -> Option<Serializable<'_>>
sourceimpl Struct for PhysicMaterial
impl Struct for PhysicMaterial
sourcefn field_at_mut(&mut self, index: usize) -> Option<&mut dyn Reflect>
fn field_at_mut(&mut self, index: usize) -> Option<&mut dyn Reflect>
index
as a &mut dyn Reflect
. Read moresourcefn name_at(&self, index: usize) -> Option<&str>
fn name_at(&self, index: usize) -> Option<&str>
index
.sourcefn iter_fields(&self) -> FieldIter<'_>
fn iter_fields(&self) -> FieldIter<'_>
sourcefn clone_dynamic(&self) -> DynamicStruct
fn clone_dynamic(&self) -> DynamicStruct
DynamicStruct
].sourceimpl Typed for PhysicMaterial
impl Typed for PhysicMaterial
impl Copy for PhysicMaterial
impl StructuralPartialEq for PhysicMaterial
Auto Trait Implementations
impl RefUnwindSafe for PhysicMaterial
impl Send for PhysicMaterial
impl Sync for PhysicMaterial
impl Unpin for PhysicMaterial
impl UnwindSafe for PhysicMaterial
Blanket Implementations
impl<T, U> AsBindGroupShaderType<U> for Twhere
U: ShaderType,
&'a T: for<'a> Into<U>,
impl<T, U> AsBindGroupShaderType<U> for Twhere
U: ShaderType,
&'a T: for<'a> Into<U>,
fn as_bind_group_shader_type(
&self,
_images: &HashMap<Handle<Image>, <Image as RenderAsset>::PreparedAsset, RandomState, Global>
) -> U
fn as_bind_group_shader_type(
&self,
_images: &HashMap<Handle<Image>, <Image as RenderAsset>::PreparedAsset, RandomState, Global>
) -> U
T
[ShaderType
] for self
. When used in [AsBindGroup
]
derives, it is safe to assume that all images in self
exist. Read moresourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
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 morefn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
. Read morefn 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. Read morefn 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. Read moreimpl<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
Self
using data from the given [World]impl<S> GetField for Swhere
S: Struct,
impl<S> GetField for Swhere
S: Struct,
impl<T> GetPath for Twhere
T: Reflect,
impl<T> GetPath for Twhere
T: Reflect,
fn path<'r, 'p>(
&'r self,
path: &'p str
) -> Result<&'r (dyn Reflect + 'static), ReflectPathError<'p>>
fn path<'r, 'p>(
&'r self,
path: &'p str
) -> Result<&'r (dyn Reflect + 'static), ReflectPathError<'p>>
path
. Read morefn path_mut<'r, 'p>(
&'r mut self,
path: &'p str
) -> Result<&'r mut (dyn Reflect + 'static), ReflectPathError<'p>>
fn path_mut<'r, 'p>(
&'r mut self,
path: &'p str
) -> Result<&'r mut (dyn Reflect + 'static), ReflectPathError<'p>>
path
. Read morefn get_path<T, 'r, 'p>(
&'r self,
path: &'p str
) -> Result<&'r T, ReflectPathError<'p>>where
T: Reflect,
fn get_path<T, 'r, 'p>(
&'r self,
path: &'p str
) -> Result<&'r T, ReflectPathError<'p>>where
T: Reflect,
path
.fn get_path_mut<T, 'r, 'p>(
&'r mut self,
path: &'p str
) -> Result<&'r mut T, ReflectPathError<'p>>where
T: Reflect,
fn get_path_mut<T, 'r, 'p>(
&'r mut self,
path: &'p str
) -> Result<&'r mut T, ReflectPathError<'p>>where
T: Reflect,
path
. Read more