Crate bevy_fly_camera

source ·
Expand description

A simple plugin and components for 2d/3d flying cameras in Bevy.

3D

Movement system is based on Minecraft, flying along the horizontal plane no matter the mouse’s vertical angle, with two extra buttons for moving vertically.

Default keybinds are:

  • W / A / S / D - Move along the horizontal plane
  • Shift - Move downward
  • Space - Move upward

Example

use bevy::prelude::*;
use bevy_fly_camera::{FlyCamera, FlyCameraPlugin};

fn setup(commands: &mut Commands) {
  commands
    .spawn(Camera3dBundle::default())
    .with(FlyCamera::default());
}

fn main() {
  App::build()
    .add_plugins(DefaultPlugins)
    .add_startup_system(setup.system())
    .add_plugin(FlyCameraPlugin)
    .run();
}

There’s also a basic piece of example code included in /examples/basic.rs

2D

Movement system only uses the keyboard to move in all four directions across the 2d plane.

The default keybinds are:

  • W / A / S / D - Move along the 2d plane

Example

use bevy::prelude::*;
use bevy_fly_camera::{FlyCamera2d, FlyCameraPlugin};
commands
  .spawn(Camera2dBundle::default())
  .with(FlyCamera2d::default());

There’s also a basic piece of example code included in /examples/2d.rs

Structs

  • A set of options for initializing a FlyCamera. Attach this component to a Camera3dBundle bundle to control it with your mouse and keyboard.
  • A set of options for initializing a FlyCamera. Attach this component to a Camera2dBundle bundle to control it with your keyboard.
  • Include this plugin to add the systems for the FlyCamera bundle.