Struct heron_core::Velocity[][src]

pub struct Velocity {
    pub linear: Vec3,
    pub angular: AxisAngle,
}

Component that defines the linear and angular velocity.

The linear part is in "unit" per second on each axis, represented as a Vec3. (The unit, being your game unit, be it pixel or anything else) The angular part is in radians per second around an axis, represented as a Quat

Example


fn spawn(commands: &mut Commands) {
    commands.spawn(todo!("Spawn your sprite/mesh, incl. at least a GlobalTransform"))
        .with(Body::Sphere { radius: 1.0 })
        .with(
            Velocity::from_linear(Vec3::unit_x() * 10.0)
                .with_angular(AxisAngle::new(Vec3::unit_z(), 0.5 * PI))
        );
}

Fields

linear: Vec3

Linear velocity in units-per-second on each axis

angular: AxisAngle

Angular velocity in radians-per-second around an axis

Implementations

impl Velocity[src]

#[must_use]pub fn from_linear(linear: Vec3) -> Self[src]

Returns a linear velocity from a vector

#[must_use]pub fn from_angular(angular: AxisAngle) -> Self[src]

Returns an angular velocity from a vector

#[must_use]pub fn with_linear(self, linear: Vec3) -> Self[src]

Returns a new version with the given linear velocity

#[must_use]pub fn with_angular(self, angular: AxisAngle) -> Self[src]

Returns a new version with the given angular velocity

Trait Implementations

impl Clone for Velocity[src]

impl Copy for Velocity[src]

impl Debug for Velocity[src]

impl Default for Velocity[src]

impl From<AxisAngle> for Velocity[src]

impl From<Quat> for Velocity[src]

impl From<Vec2> for Velocity[src]

impl From<Vec3> for Velocity[src]

impl From<Velocity> for AxisAngle[src]

impl NearZero for Velocity[src]

impl PartialEq<Velocity> for Velocity[src]

impl StructuralPartialEq for Velocity[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Component for T where
    T: 'static + Send + Sync
[src]

impl<T> Downcast for T where
    T: Any

impl<T> DowncastSync for T where
    T: Send + Sync + Any

impl<T> From<T> for T[src]

impl<T> FromResources for T where
    T: Default
[src]

impl<T> Instrument for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Resource for T where
    T: 'static + Send + Sync
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> TypeData for T where
    T: 'static + Send + Sync + Clone

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,