use Mul<f32> to double the value of Vec3 (#6607)

improve the example code
This commit is contained in:
Hsiang-Cheng Yang 2022-11-14 23:08:30 +00:00
parent 6993f3cfe3
commit eaa35cf99f

View File

@ -175,8 +175,7 @@ fn integrate(mut query: Query<(&mut Acceleration, &mut Transform, &mut LastPos)>
// verlet integration
// x(t+dt) = 2x(t) - x(t-dt) + a(t)dt^2 + O(dt^4)
let new_pos =
transform.translation + transform.translation - last_pos.0 + acceleration.0 * dt_sq;
let new_pos = transform.translation * 2.0 - last_pos.0 + acceleration.0 * dt_sq;
acceleration.0 = Vec3::ZERO;
last_pos.0 = transform.translation;
transform.translation = new_pos;