HydrogenC / bevy_flycam

Basic first-person fly camera for the Bevy game engine

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

bevy_flycam

Crates.io Crates.io docs.rs

A basic first-person fly camera for Bevy 0.4

Controls

  • WASD to move horizontally
  • SPACE to ascend
  • LSHIFT to descend
  • ESC to grab/release cursor.

Comparison

There are a few notable differences from bevy_fly_camera...

  • No linear interpolation
  • Cursor grabbing
  • Shorter code
  • Single-line setup
  • A tiny bit faster?

Usage

  1. Add to Cargo.toml or copy lib.rs to your own file
[dependencies]
bevy = "0.4"
bevy_flycam = "*"

or

[dependencies]
bevy = "0.4"
bevy_flycam = { git = "https://github.com/sburris0/bevy_flycam" }
  1. 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 .with(FlyCam) on your own camera or else this plugin won't know what to move.

  1. Add the PlayerPlugin:
#[bevy_main]
fn main() {
    App::build()
        .add_plugins(DefaultPlugins)
        .add_plugin(PlayerPlugin)
        .run();
}

Customization

To modify player movement speed or mouse sensitivity, import bevy_flycam::MovementSettings and add it as a resource:

#[bevy_main]
fn main() {
    App::build()
        .add_plugins(DefaultPlugins)
        .add_plugin(PlayerPlugin)
        .add_resource(MovementSettings {
            sensitivity: 0.00015, // default: 0.00012
            speed: 150.0, // default: 12.0
        })
        .run();
}

Contributing

PRs are very welcome.

About

Basic first-person fly camera for the Bevy game engine

License:ISC License


Languages

Language:Rust 100.0%