Crates.io | bevy_flycam |
lib.rs | bevy_flycam |
version | 0.14.1 |
source | src |
created_at | 2021-01-03 03:17:03.609887 |
updated_at | 2024-07-18 23:21:41.278065 |
description | Basic first-person fly camera for the Bevy game engine |
homepage | https://github.com/sburris0/bevy_flycam/ |
repository | https://github.com/sburris0/bevy_flycam/ |
max_upload_size | |
id | 330858 |
size | 114,054 |
A basic first-person fly camera for Bevy 0.14
There are a few notable differences from bevy_fly_camera...
Add to Cargo.toml
or copy lib.rs
to your own file
[dependencies]
bevy = "0.14"
bevy_flycam = "*"
or
[dependencies]
bevy = "0.14"
bevy_flycam = { git = "https://github.com/sburris0/bevy_flycam" }
Include the prelude:
use bevy_flycam::prelude::*;
Add the PlayerPlugin
:
#[bevy_main]
fn main() {
App::new()
.add_plugins(DefaultPlugins)
.add_plugins(PlayerPlugin)
.run();
}
Note that PlayerPlugin
will spawn a camera for you. See 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
To modify player movement speed or mouse sensitivity add it as a resource. Same thing goes for the keybindings used for moving the camera.
#[bevy_main]
fn main() {
App::new()
.add_plugins(DefaultPlugins)
.add_plugins(PlayerPlugin)
.insert_resource(MovementSettings {
sensitivity: 0.00015, // default: 0.00012
speed: 12.0, // default: 12.0
})
.insert_resource(KeyBindings {
move_ascend: KeyCode::E,
move_descend: KeyCode::Q,
..Default::default()
})
.run();
}
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.
#[bevy_main]
fn main() {
App::new()
.add_plugins(DefaultPlugins)
.add_plugin(NoCameraPlayerPlugin)
.add_systems(Startup, setup)
.run();
}
fn setup(mut commands: Commands) {
commands.spawn((
Camera3dBundle {
transform: Transform::from_xyz(0.0, 2.0, 0.5),
..default()
},
FlyCam
));
}
bevy_flycam's crate version follows bevy's minor version as shown:
bevy | bevy_flycam |
---|---|
0.14.0 |
0.14.0 |
0.13.0 |
0.13.0 |
0.12.0 |
0.12.0 |
0.11.0 |
0.11.0 |
0.10.1 |
0.10.1 |
PRs are very welcome.