pub struct TnuaProximitySensor {
pub cast_origin: Vector3,
pub cast_direction: Dir3,
pub cast_range: Float,
pub output: Option<TnuaProximitySensorOutput>,
pub intersection_match_prevention_cutoff: Float,
}
Expand description
Distance from another collider in a certain direction, and information on that collider.
The physics backend is responsible for updating this component from the physics engine during
TnuaPipelineStages::Sensors
, usually by casting a ray
or a shape in the cast_direction
.
Fields§
§cast_origin: Vector3
The cast origin in the entity’s coord system.
cast_direction: Dir3
The direction in world coord system (unmodified by the entity’s transform)
cast_range: Float
Tnua will update this field according to its need. The backend only needs to read it.
output: Option<TnuaProximitySensorOutput>
§intersection_match_prevention_cutoff: Float
Used to prevent collision with obstacles the character squeezed into sideways.
This is used to prevent https://github.com/idanarye/bevy-tnua/issues/14. When casting, Tnua checks if the entity the ray(/shape)cast hits is also in contact with the owner collider. If so, Tnua compares the contact normal with the cast direction.
For legitimate hits, these two directions should be opposite. If Tnua casts downwards and
hits the actual floor, the normal of the contact with it should point upward. Opposite
directions means the dot product is closer to -1.0
.
Illigitimage hits hits would have perpendicular directions - hitting a wall (sideways) when
casting downwards - which should give a dot product closer to 0.0
.
This field is compared to the dot product to determine if the hit is valid or not, and can
usually be left at the default value of -0.5
.
Positive dot products should not happen (hitting the ceiling?), but it’s trivial to consider them as invalid.
Trait Implementations§
source§impl Component for TnuaProximitySensor
impl Component for TnuaProximitySensor
source§const STORAGE_TYPE: StorageType = bevy::ecs::component::StorageType::Table
const STORAGE_TYPE: StorageType = bevy::ecs::component::StorageType::Table
source§fn register_component_hooks(_hooks: &mut ComponentHooks)
fn register_component_hooks(_hooks: &mut ComponentHooks)
ComponentHooks
.source§impl Debug for TnuaProximitySensor
impl Debug for TnuaProximitySensor
Auto Trait Implementations§
impl Freeze for TnuaProximitySensor
impl RefUnwindSafe for TnuaProximitySensor
impl Send for TnuaProximitySensor
impl Sync for TnuaProximitySensor
impl Unpin for TnuaProximitySensor
impl UnwindSafe for TnuaProximitySensor
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 Components, storages: &mut Storages, ids: &mut impl FnMut(ComponentId) )
unsafe fn from_components<T, F>(ctx: &mut T, func: &mut F) -> C
source§fn get_component_ids(
components: &Components,
ids: &mut impl FnMut(Option<ComponentId>)
)
fn get_component_ids( components: &Components, ids: &mut impl FnMut(Option<ComponentId>) )
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>
. Box<dyn Any>
can
then be further downcast
into Box<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>
. Rc<Any>
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> DowncastSync for T
impl<T> DowncastSync for T
source§impl<C> DynamicBundle for Cwhere
C: Component,
impl<C> DynamicBundle for Cwhere
C: Component,
fn get_components(self, func: &mut impl FnMut(StorageType, OwningPtr<'_>))
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
Self
using data from the given World
.