Expand description

This library provides a simple, lightweight way of having a “flycam” style camera for debugging. It’s confirgurable, letting you easily enable the system locally for a camera or globally for all cameras with a component and resource.

Bevy compatibility

Bevy Versionbevy-debug-camera version
0.9.1^0.1.0
^0.10.0^0.2.0
^0.11.0^0.3.0

Examples

You can look at the examples folder for practical uses of this crate, but to get started you can simply do the following when setting up your app:

use bevy::prelude::*;
use bevy_debug_camera::{DebugCamera, DebugCameraPlugin};

fn main() {
    App::new()
        .add_plugins(DefaultPlugins)
        .add_plugin(DebugCameraPlugin::default())
        .add_startup_system(setup)
        .run();
}

fn setup(mut commands: Commands) {
    // ... other setup code
    commands
        .spawn(Camera3dBundle::default())
        .insert(DebugCamera {
            position: Vec3::new(-5., 1., 0.),
            ..default()
        });
}

Bindings

The default bindings are as follows:

Mouse + Keyboard

ActionBinding
Move forwardW
Move backwardS
Move leftA
Move rightD
Move upLshift
Move downSpace
YawMouse X
pitchMouse Y
Roll leftQ
Roll rightE

Controller

ActionBinding
Move fwd/bwdLstick Y
Move left/rightLstick X
Move upRTrigger
Move downLTrigger
YawRstick X
pitchLstick Y
Roll leftLBumper
Roll rightRBumper

Configuring Plugin

The plugin comes with some configuration options you can set on startup that use to customise behaviour of the cameras in use. You can configure:

  • Keyboard bindings
  • Gamepad bindings
  • Accepted input

All these customisation are exposed as resources, which are constantly read and can be modified during runtime as well An example using all configuration options can be seen below and in the configuration example:

use bevy::prelude::*;
use bevy_debug_camera::{
    DebugCamera, DebugCameraPlugin, GamepadBindings, KeyboardBindings, DebugCameraActive,
};

fn main() {
    App::new()
        .add_plugins(DefaultPlugins)
        // Each field in `DebugCameraPlugin` can be set directly or picked up from
        // default.
        .add_plugin(DebugCameraPlugin {
            gamepad_bindings: GamepadBindings {
                // Overrides only the roll buttons
                roll_left: GamepadButtonType::West,
                roll_right: GamepadButtonType::East,
                ..default()
            },
            keyboard_bindings: KeyboardBindings {
                // Override WASD with arrows
                fwd: KeyCode::Up,
                bwd: KeyCode::Down,
                left: KeyCode::Left,
                right: KeyCode::Right,
                ..default()
            },
            debug_camera_active: DebugCameraActive {
                // Disable keyboard + mouse only
                keymouse: false,
                ..default()
            },
        })
        .add_startup_system(setup)
        .run();
}

fn setup() {
    // Setup logic here...
}

Structs

  • Any entity with this component will be controllable using the default bindings for this plugin. For more information on controls, refer to the crate root.
  • This system signals whether the debug camera should be active. You can selectively pick which input types are active at a given time. You can
  • Configurable bindings for gamepad input. Field defaults can be found in the crate root documentation.
  • Configurable bindings for keyboard input. Field defaults can be found in the crate root documentation.