bevy_tnua::util

Trait MotionHelper

Source
pub trait MotionHelper {
Show 13 methods // Required methods fn frame_duration(&self) -> Float; fn up_direction(&self) -> Dir3; fn gravity(&self) -> Vector3; fn position(&self) -> Vector3; fn velocity(&self) -> Vector3; fn rotation(&self) -> Quaternion; fn angvel(&self) -> Vector3; // Provided methods fn negate_gravity(&self) -> TnuaVelChange { ... } fn adjust_velocity( &self, target: Vector3, acceleration: Float, dimlim: impl Fn(Vector3) -> Vector3, ) -> TnuaVelChange { ... } fn adjust_vertical_velocity( &self, target: Float, acceleration: Float, ) -> TnuaVelChange { ... } fn adjust_horizontal_velocity( &self, target: Vector3, acceleration: Float, ) -> TnuaVelChange { ... } fn turn_to_direction( &self, desired_forward: Dir3, up_direction: Dir3, ) -> TnuaVelChange { ... } fn hard_stop( &self, direction: Dir3, stop_at: Vector3, current_vel_change: &TnuaVelChange, ) -> TnuaVelChange { ... }
}
Expand description

Helper trait for implementing basis and actions.

Methods of this trait typically return a TnuaVelChange that can be added to motor.lin or motor.ang.

Required Methods§

Provided Methods§

Source

fn negate_gravity(&self) -> TnuaVelChange

A force for cancelling out the gravity.

Source

fn adjust_velocity( &self, target: Vector3, acceleration: Float, dimlim: impl Fn(Vector3) -> Vector3, ) -> TnuaVelChange

A force for setting the velocity to the desired velocity, with acceleration constraints.

The dimlim parameter can be used to only set the velocity on certain axis/plane.

Source

fn adjust_vertical_velocity( &self, target: Float, acceleration: Float, ) -> TnuaVelChange

A force for setting the vertical velocity to the desired velocity, with acceleration constraints.

Source

fn adjust_horizontal_velocity( &self, target: Vector3, acceleration: Float, ) -> TnuaVelChange

A force for setting the horizontal velocity to the desired velocity, with acceleration constraints.

Source

fn turn_to_direction( &self, desired_forward: Dir3, up_direction: Dir3, ) -> TnuaVelChange

Calculate the rotation around up_direction required to rotate the character from the current forward to desired_forward.

Source

fn hard_stop( &self, direction: Dir3, stop_at: Vector3, current_vel_change: &TnuaVelChange, ) -> TnuaVelChange

A force for stopping the character right before reaching a certain point.

Please note that unlike most MotionHelper methods that “stack” on impulses and forces already applied, this one needs to be able to “cancel” the previous changes (on the relevant axis, at least) which is why it has a current_vel_change argument. Due to that, this must be the last velchange applied to the motor (at least, to it’s lin field, on the axis of direction)

direction is the direction from the character toward that point. So, for example, in order to stop a character climbing a ladder when reaching the top of the ladder, stop_at needs to be the coordinates of the top of the ladder while direction needs to be Dir3::Y (the UP direction)

Velocities perpendicular to the direction will not be affected.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§