From 84747e1c3afd20cfd2be0065739e837d88c4ef7b Mon Sep 17 00:00:00 2001 From: hut Date: Mon, 1 Apr 2024 19:20:31 +0200 Subject: [PATCH] add CENTER_WORLD_ON_PLAYER constant --- src/world.rs | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/world.rs b/src/world.rs index ac9ce9b..3c4d377 100644 --- a/src/world.rs +++ b/src/world.rs @@ -10,6 +10,8 @@ const ASTEROID_UPDATE_INTERVAL: f32 = 1.0; // seconds const ASTEROID_SIZE: f32 = 100.0; const STARS_MAX_MAGNITUDE: f32 = 5.5; +const CENTER_WORLD_ON_PLAYER: bool = true; + const ASSET_ASTEROID1: &str = "models/asteroid.glb#Scene0"; const ASSET_ASTEROID2: &str = "models/asteroid2.glb#Scene0"; pub fn asset_name_to_path(name: &str) -> &'static str { @@ -42,13 +44,15 @@ impl Plugin for WorldPlugin { Timer::from_seconds(ASTEROID_UPDATE_INTERVAL, TimerMode::Repeating))); app.insert_resource(AsteroidDatabase(Vec::new())); - // Disable bevy_xpbd's position->transform sync because we have a - // custom syncing function. - app.insert_resource(SyncConfig { - position_to_transform: false, - transform_to_position: false, - }); - app.add_systems(PreUpdate, position_to_transform); + if CENTER_WORLD_ON_PLAYER { + // Disable bevy_xpbd's position->transform sync function + app.insert_resource(SyncConfig { + position_to_transform: false, + transform_to_position: false, + }); + // Add own position->transform sync function + app.add_systems(PreUpdate, position_to_transform); + } } }