Add AngularVelocity, begin removal of Rotation
The rotation component is also redundant with Bevy's transform component. This new component and system fill the physics role, but the input handling code needs to be updated. Player steering still functions because it uses the `Rotation` component to direct the force vector. The force is correctly applied to the linear velocity vector. An improvement would be to have a force/impulse accumulator so I could account for mass, but I'm not going to do that right now.
This commit is contained in:
@@ -26,12 +26,15 @@ pub(crate) fn integrate_velocity(mut query: Query<(&mut Transform, &Velocity)>,
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Assigns the rotation to the transform by copying it from the Rotation component.
|
||||
*/
|
||||
pub(crate) fn apply_rotation_to_mesh(mut query: Query<(&mut Transform, &Rotation)>) {
|
||||
for (mut transform, rotation) in &mut query {
|
||||
transform.rotation = Quat::from_rotation_z(rotation.0);
|
||||
/// Integrate angular velocity and update the entity's transform.
|
||||
pub(crate) fn integrate_angular_velocity(
|
||||
mut objects: Query<(&mut Transform, &AngularVelocity)>,
|
||||
time: Res<Time>,
|
||||
) {
|
||||
for (mut transform, ang_vel) in &mut objects {
|
||||
let delta = ang_vel.0 * time.delta_secs();
|
||||
let temp = transform.rotation + Quat::from_rotation_z(delta);
|
||||
transform.rotation = temp;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user