Coder Social home page Coder Social logo

bevy_flycam's Introduction

bevy_flycam

Crates.io Crates.io docs.rs

A basic first-person fly camera for Bevy 0.9

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.9"
bevy_flycam = "*"

or

[dependencies]
bevy = "0.9"
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 .insert(FlyCam) on your own camera or else this plugin won't know what to move.

  1. 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

Customization

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();
}

Support

Bevy tracking

bevy_flycam's crate version follows bevy's X version as shown:

bevy bevy_flycam
0.X.Y 0.X

Contributing

PRs are very welcome.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.