bevy_dolly
is a prototype plugin using h3r2tic's powerful crate: dolly, implemented for bevy.
⚠ Feedback - Bevy_dolly's API is still being revised, so feedback on ergonomics and DX is highly appreciated ⚠
It is important to note that dolly is a way to control the movement of the camera and thus, not the camera component itself.
Dolly requires two steps to function:
- Creating a
Rig
we are able to define drivers on which the dolly can enact, these drivers can both be constraints and functionality. - A marker component that is registered on both the Camera and the Rig.
Explain what drivers are
To read more about the different drivers.
#[derive(Component)]
struct MainCamera;
fn main() {
App::new()
.add_plugins(DefaultPlugins)
.add_startup_system(setup)
//..
.add_system(Dolly::<MainCamera>::update_active)
//..
.run();
}
// In your setup system
fn setup(
mut commands: Commands,
) {
commands.spawn((
MainCamera, // The rig tag
Rig::builder()
.with(Position::new(Vec3::ZERO))
.with(YawPitch::new().yaw_degrees(45.0).pitch_degrees(-30.0))
.with(Smooth::new_position(0.3))
.with(Smooth::new_rotation(0.3))
.with(Arm::new(Vec3::Z * 4.0))
.build(),
Camera3dBundle::default(),
));
}
Link to examples readme
This plugin currently also provides some helper plugins, which. They are enabled by default but are not needed and can be removed when setting up bevy_dolly's dependency:
[dependencies]
bevy_dolly = { version = "0.0.1", default-features = false }
Note this will also remove the bevy_dolly's extended drivers and add features = ["drivers"],
to include the drivers back.
To see how works in Bevy in practice, please look at this repository's examples.
cargo run --release --example orbit
bevy | bevy_dolly |
---|---|
0.11 | 0.0.1 |
There is a bunch of other bevy camera controllers that are worth checking out, especially if you are just starting out learning bevy:
- bevy_fps_controller - A Fps controller with crouching, sprinting, flymode and more
- smooth-bevy-cameras - 3 Smooth Camera controllers: Fps, Orbit or Unreal
- bevy_spectator - A spectator camera controller
- bevy_flycam - A simple fly camera
- bevy_fly_camera - A advanced fly camera
- bevy_pancam - 2D Click and Drag - Style camera movement
- bevy_config_cam - Plugin that enables to use collection of different camera controllers at runtime, uses bevy_dolly as the backend
The project is under dual license MIT and Apache 2.0, so joink to your hearts content, just remember the license agreements.
Yes this project is still very much WIP, so PRs are very welcome.
The dolly
dependency used is a slightly patched submodule, so to build the crate locally you must first run the following:
git submodule update --init --recursive