pub struct VelocityBoundary {
pub direction: Dir3,
/* private fields */
}
Expand description
An indication that a character was knocked back and “struggles” to get back to its original velocity.
Fields§
§direction: Dir3
Implementations§
Source§impl VelocityBoundary
impl VelocityBoundary
pub fn new( disruption_from: Vector3, disruption_to: Vector3, no_push_timeout: f32, ) -> Option<Self>
Sourcepub fn update(&mut self, velocity: Vector3, frame_duration: Duration)
pub fn update(&mut self, velocity: Vector3, frame_duration: Duration)
Call this every frame to update the velocity boundary.
This methos takes care of “clearing” the boundary when it gets “pushed” (the character’s actual velocity goes past the boundary).
This method does not detect when the boundary is cleared - use
is_cleared
for that purpose
This method does not apply the boundary - it only updates it. To apply the boundary, use
calc_boost_part_on_boundary_axis_after_limit
to determine how to alter the acceleration.
§Arguments:
velocity
- the velocity as reported by the physics backend. This is the data tracked in theTnuaRigidBodyTracker
, so a typical basis or action will get it fromTnuaBasisContext::tracker
.frame_duration
- the duration of the current frame, in seconds.
pub fn is_cleared(&self) -> bool
Sourcepub fn calc_boost_part_on_boundary_axis_after_limit(
&self,
current_velocity: Vector3,
regular_boost: Vector3,
boost_limit_inside_barrier: Float,
barrier_strength_diminishing: Float,
) -> Option<(Dir3, Float)>
pub fn calc_boost_part_on_boundary_axis_after_limit( &self, current_velocity: Vector3, regular_boost: Vector3, boost_limit_inside_barrier: Float, barrier_strength_diminishing: Float, ) -> Option<(Dir3, Float)>
Calculate how a boost needs to be adjusted according to the boundary.
Note that the returned value is the boost limit only on the axis of the returned direction.
The other axes should remain the same (unless the caller has a good reason to modify them).
The reason why this method doesn’t simply return the final boost is that the caller may be
using TnuaVelChange
which combines acceleration and impulse, and
if so then it is the caller’s responsibility to amend the result of this method to match
that scheme.
§Arguments:
current_velocity
- the velocity of the character before the boost.regular_boost
- the boost that the caller would have applied to the character before taking the boundary into account.boost_limit_inside_barrier
- the maximum boost allowed inside a fully strength barrier, assuming it goes directly against the direction of the boundary.barrier_strength_diminishing
- an exponent describing how the boundary strength diminishes when the barrier gets cleared. For best results, set it to values larger than 1.0.
Trait Implementations§
Source§impl Clone for VelocityBoundary
impl Clone for VelocityBoundary
Source§fn clone(&self) -> VelocityBoundary
fn clone(&self) -> VelocityBoundary
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreAuto Trait Implementations§
impl Freeze for VelocityBoundary
impl RefUnwindSafe for VelocityBoundary
impl Send for VelocityBoundary
impl Sync for VelocityBoundary
impl Unpin for VelocityBoundary
impl UnwindSafe for VelocityBoundary
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<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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
Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
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