Add camera delay
This commit is contained in:
+4
-1
@@ -11,8 +11,11 @@ fn spawn_camera(mut commands: Commands) {
|
||||
fn follow_player(
|
||||
player: Single<&Transform, (With<Player>, Without<Camera2d>)>,
|
||||
mut camera: Single<&mut Transform, (With<Camera2d>, Without<Player>)>,
|
||||
time: Res<Time>,
|
||||
// camera.translation.y = player.translation.y; // without delay
|
||||
) {
|
||||
camera.translation.y = player.translation.y;
|
||||
camera.translation.y = camera.translation.y
|
||||
+ (player.translation.y - camera.translation.y) * 3.0 * time.delta_secs(); // with delay
|
||||
}
|
||||
|
||||
pub struct CameraPlugin;
|
||||
|
||||
Reference in New Issue
Block a user