A basic first-person-shooter player controller for Bevy 0.4
- WASD to move
- SPACE to ascend
- LSHIFT to sprint
- ESC to grab/release cursor.
This is more or less a copy of bevy_flycam...
- Rigidbody
- Gravity
- Running
- Add to
Cargo.toml
or copylib.rs
to your own file
[dependencies]
bevy = "0.4"
bevy_fps_controller = "*"
or
[dependencies]
bevy = "0.4"
bevy_fps_controller = { git = "https://github.com/mglolenstine/bevy_fps_controller" }
- Include the
FPSControllerPlugin
use bevy_fps_controller::FPSControllerPlugin;
This will spawn a camera for you.
Use NoControllerPlugin
if you do not want this and make sure to use .with(FPSController)
on your own player or else this plugin won't know what to move.
- Add the
FPSControllerPlugin
:
#[bevy_main]
fn main() {
App::build()
.add_plugins(DefaultPlugins)
.add_plugin(FPSControllerPlugin)
.run();
}
To modify player movement speed, sprint multiplier or mouse sensitivity, import bevy_fps_controller::MovementSettings
and add it as a resource:
#[bevy_main]
fn main() {
App::build()
.add_plugins(DefaultPlugins)
.add_plugin(FPSControllerPlugin)
.add_resource(MovementSettings {
sensitivity: 0.00015, // default: 0.00006
speed: 150.0, // default: 12.0
speed_multiplier: 1.2, // default: 1.5
})
.run();
}
PRs are very welcome.