Made orientation change with move_dir, added a small amount of knockback

This commit is contained in:
Joshua Barretto 2019-08-03 18:24:07 +01:00
parent 5e3e87f9c5
commit e52250a193
2 changed files with 7 additions and 10 deletions

View File

@ -54,7 +54,8 @@ impl<'a> System<'a> for Sys {
stat_b
.health
.change_by(-10, HealthSource::Attack { by: *uid }); // TODO: variable damage and weapon
vel_b.0.z = 4.0;
vel_b.0 += (pos_b.0 - pos.0).normalized() * 5.0;
vel_b.0.z = 10.0;
let _ = force_updates.insert(b, ForceUpdate);
}
}

View File

@ -109,6 +109,11 @@ impl<'a> System<'a> for Sys {
}
_ => 0.0,
};
// Set direction based on move direction when on the ground
if Vec2::<f32>::from(move_dir.0).magnitude_squared() > 0.0001 {
ori.0 = Lerp::lerp(ori.0, Vec3::from(move_dir.0.normalized()), 4.0 * dt.0);
}
}
// Jump
@ -132,15 +137,6 @@ impl<'a> System<'a> for Sys {
rollings.remove(entity);
}
}
// Set direction based on velocity when on the ground
if Vec2::<f32>::from(vel.0).magnitude_squared() > 0.0001 {
ori.0 = Lerp::lerp(
ori.0,
vel.0.normalized() * Vec3::new(1.0, 1.0, 0.0),
10.0 * dt.0,
);
}
}
}
}