From a237a474bebb5f50e4a79841fdb63ef38e2a929f Mon Sep 17 00:00:00 2001 From: Atul Varma Date: Sun, 4 Jun 2023 06:21:06 -0400 Subject: [PATCH] Add NoCameraPlayerPlugin example to README.md --- README.md | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 9abae1d..e03630f 100644 --- a/README.md +++ b/README.md @@ -47,9 +47,6 @@ There are a few notable differences from [bevy_fly_camera](https://github.com/mc use bevy_flycam::prelude::*; ``` - This will spawn a camera for you. - Use `NoCameraPlayerPlugin` if you do not want this and make sure to use `.insert(FlyCam)` on your own camera or else this plugin won't know what to move. - 3. Add the `PlayerPlugin`: ```rust @@ -62,11 +59,16 @@ There are a few notable differences from [bevy_fly_camera](https://github.com/mc } ``` +Note that `PlayerPlugin` will spawn a camera for you. See [Using your own camera](#using-your-own-camera) for details on how to +use a pre-existing one. + Alternatively you can see the example `basic.rs` or `scroll.rs` located in the examples folder. You can run the example by cloning this repository and run the command: `cargo run --release --example basic` ## Customization +### Movement and keybindings + To modify player movement speed or mouse sensitivity add it as a resource.
Same thing goes for the keybindings used for moving the camera. @@ -89,6 +91,31 @@ fn main() { } ``` +### Using your own camera + +You can also use `NoCameraPlayerPlugin` if you want to use your own camera. Be sure to add the `FlyCam` component to your own camera or else this plugin won't know what to move. + +```Rust +#[bevy_main] +fn main() { + App::new() + .add_plugins(DefaultPlugins) + .add_plugin(NoCameraPlayerPlugin) + .add_startup_system(setup) + .run(); +} + +fn setup(mut commands: Commands) { + commands.spawn(( + Camera3dBundle { + transform: Transform::from_xyz(0.0, 2.0, 0.5), + ..default() + }, + FlyCam + )); +} +``` + ## Support [![Bevy tracking](https://img.shields.io/badge/Bevy%20tracking-released%20version-lightblue)](https://github.com/bevyengine/bevy/blob/main/docs/plugins_guidelines.md#main-branch-tracking)