A basic first-person fly camera for Bevy 0.7
- WASD to move horizontally
- SPACE to ascend
- LSHIFT to descend
- ESC to grab/release cursor.
There are a few notable differences from bevy_fly_camera...
- No linear interpolation
- Cursor grabbing
- Shorter code
- Single-line setup
- A tiny bit faster?
- Add to
Cargo.tomlor copylib.rsto your own file
[dependencies]
bevy = "0.7"
bevy_flycam = "*"or
[dependencies]
bevy = "0.7"
bevy_flycam = { git = "https://github.com/sburris0/bevy_flycam" }- Include the
PlayerPlugin
use bevy_flycam::PlayerPlugin;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.
- Add the
PlayerPlugin:
#[bevy_main]
fn main() {
App::new()
.add_plugins(DefaultPlugins)
.add_plugin(PlayerPlugin)
.run();
}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
To modify player movement speed or mouse sensitivity, import bevy_flycam::MovementSettings and add it as a resource:
#[bevy_main]
fn main() {
App::new()
.add_plugins(DefaultPlugins)
.add_plugin(PlayerPlugin)
.insert_resource(MovementSettings {
sensitivity: 0.00015, // default: 0.00012
speed: 12.0, // default: 12.0
})
.run();
}bevy_flycam's crate version follows bevy's X version as shown:
| bevy | bevy_flycam |
|---|---|
| 0.X.Y | 0.X |
PRs are very welcome.