- Notifications
You must be signed in to change notification settings - Fork3
Top down camera for Bevy engine
License
Apache-2.0, MIT licenses found
Licenses found
olekspickle/bevy_top_down_camera
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
- Move around by hovering cursor to the edges of the screen
- Zoom in/out
- Rotate horizontally to change observable angle preserving pitch and yaw
- Follow target
Add thebevy_top_down_camera crate:
cargo add bevy_third_person_cameraImport thebevy_top_down_camera crate:
use bevy_top_down_camera::*;
Add theTopDownCameraPlugin:
.add_plugins(TopDownCameraPlugin)
Add theTopDownCamera component to the camera entity:
commands.spawn((Camera3d::default(),TopDownCamera::default(),));
If you want camera to follow the player, add theTopDownCameraTarget component to your player:
// Playercommands.spawn((MeshMaterial3d(materials.add(Color::WHITE)),Mesh3d(meshes.add(Mesh::from(Cuboid::new(1.0,1.0,1.0)))),Transform::from_translation(Vec3::new(0.0,0.5,0.0)),TopDownCameraTarget,Player,));
- default
cargo run --example <example name>Most settings can be overridden:
commands.spawn((// These are the default settingsTopDownCamera{follow:false,zoom_enabled:true,zoom:(5.0,50.0).into(),cursor_enabled:true,cursor_move_speed:0.2,cursor_max_speed:200.0,cursor_rotate_speed:0.01,cursor_edge_margin:Vec2::splat(30.0),mode:CameraMode::Move,initial_setup:false,height:Height::new(5.0,50.0),height_keys_enabled:true,height_rise_key:KeyCode::KeyX.into(),height_lower_key:KeyCode::KeyZ.into(),rotate_key:MouseButton::Right.into(),},Camera3d::default(),));
When using third party physics engines such as bevy rapier 3d or avian 3d, you should force the 'sync_player_camera' system to runafter the physics systems. Failing to do this will cause a jittering effect to occur when applying forces/impulses to an object that has a camera entity attached. Simply add the following to your App::new() method (also see examples/physics.rs for complete example):
.configure_sets(PostUpdate,CameraSyncSet.after(PhysicsSet::StepSimulation))// Bevy Rapier 3d.configure_sets(PostUpdate,CameraSyncSet.after(PhysicsSet::Sync))// Avian 3d
| Action | Mouse/Keyboard | Enabled by Default |
|---|---|---|
| Zoom In | Scroll Up | Yes |
| Zoom Out | Scroll Down | Yes |
| Rotate | Right Mouse Button | Yes |
| Move around | Hover to screen edges | Yes |
| Follow | - | No |
| bevy | bevy_top_down_camera |
|---|---|
| 0.16 | 0.1.0 - 0.1.5 |
- MIT License (LICENSE-MIT orhttp://opensource.org/licenses/MIT)
- Apache License, Version 2.0 (LICENSE-APACHE orhttp://www.apache.org/licenses/LICENSE-2.0)
About
Top down camera for Bevy engine
Resources
License
Apache-2.0, MIT licenses found
Licenses found
Uh oh!
There was an error while loading.Please reload this page.
