1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
use super::*;
/// Velocity component.
///
/// Use to move and rotate entities (without physics).
pub struct Velocity {
id: Entity,
}
impl std::fmt::Debug for Velocity {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("Velocity")
.field("entity", &self.id.name())
.field("velocity", &self.velocity().get())
.field("angular_velocity", &self.angular_velocity().get())
.finish()
}
}
impl Velocity {
impl_world_accessor!(
/// Returns a `ValueAccessor` for the world-space linear velocity of the entity.
///
/// Used to set/get/animate the velocity. This only works if physics has not been enabled
/// for the entity.
Velocity,
Velocity,
Vec3,
velocity,
ValueAccessorReadWriteAnimate
);
impl_world_accessor!(
/// Returns a `ValueAccessor` for the world-space angular velocity of the entity
///
/// This is an angular velocity as a pseudovector, with its magnitude measuring
/// the rate at which an object rotates or revolves (in radians per seconds), and
/// its direction pointing perpendicular to the instantaneous plane of rotation or
/// angular displacement.
///
/// Used to set/get/animate the velocity. This only works if physics has not been enabled
/// for the entity.
Velocity,
AngularVelocity,
Vec3,
angular_velocity,
ValueAccessorReadWriteAnimate
);
}
impl_world_component!(Velocity);