diff --git a/src/flycam.rs b/src/flycam.rs index 5c82a62..8dcdb40 100644 --- a/src/flycam.rs +++ b/src/flycam.rs @@ -5,12 +5,18 @@ use bevy::{ Input, }, prelude::*, + utils::tracing::info, }; // stolen with neither shame nor pity from // git@github.com:sburris0/bevy_flycam.git, b90f6fc, which is copyright 2020 // Spencer Burris +pub const PLANET_RADIUS: f32 = 75.0; + +const PLAYER_DIST: f32 = PLANET_RADIUS + 300.0; +const CAM_DIST: f32 = 25.0; + struct PlayerState { velocity: Vec3, } @@ -54,33 +60,71 @@ impl Default for MovementSettings { #[derive(Component, Debug)] pub struct FlyCam; +#[derive(Component, Debug)] +pub struct CyberBike; + /// Spawns the `Camera3dBundle` to be controlled -fn setup_player(mut commands: Commands) { +fn setup_player(mut commands: Commands, asset_server: Res) { commands .spawn_bundle(PerspectiveCameraBundle { - transform: Transform::from_xyz(0.0, 100.0, -500.0).looking_at(Vec3::ZERO, Vec3::Y), + transform: Transform::from_xyz(PLAYER_DIST + CAM_DIST, 0.0, 0.0) + .looking_at(Vec3::ZERO, Vec3::Y), ..Default::default() }) .insert(FlyCam); + + commands + .spawn_bundle(( + Transform { + translation: Vec3::new(PLAYER_DIST, 0.0, 0.0), + ..Default::default() + } + .looking_at(Vec3::ZERO, Vec3::Y), + GlobalTransform::identity(), + )) + .with_children(|rider| { + rider.spawn_scene(asset_server.load("cyber-bike_no_y_up.glb#Scene0")); + }) + .insert(CyberBike); } -/// Handles keyboard input and movement fn player_move( time: Res