6 releases
0.3.0 | Apr 19, 2022 |
---|---|
0.2.0 | Jan 31, 2022 |
0.1.3 | Oct 14, 2021 |
0.1.2 | Jun 12, 2021 |
0.1.1 | May 26, 2021 |
#2056 in Game dev
35KB
605 lines
An easy plug-n-play multifunctional camera controller that allows for easy setup of a camera and player for a scene.
Add a few lines of code to your existing project allows you to test a wide variety of cameras by attaching it to your player asset or the default red player entity.
Inspired and extended on bevy_flycam, this plugin is fairly simple but should be a neat help for developers looking for a camera implementation without going the hassle of reinventing the wheel.
Future Plans
The main goal of this plugin is to first and foremost provide the user with a configurable, extendable and easy-to-use API. dolly
by @h3r2tic is a crate that provides an framework for which to create, combine and modify camera positioning, exactly what bevy_config_cam
is looking for. So a migration to dolly
is in the works in order to improve this plugin main goal.
Showcase
Camera Modes
LookAt | FollowStatic |
---|---|
TopDown | TopDownDirection |
---|---|
FollowBehind | Fps |
---|---|
Free | ? |
---|---|
Any suggestions on other camera modes you want? Let me know by creating an issue :) |
Settings
Camera Mode | Disc. | Demo |
---|---|---|
MovementSpeed (Camera) | Change the speed of there cameras movement | |
Sensitivity | Change the sensitivity of the cameras mouse movement | |
Lerp | Change the linear interpolation between the target and the player (LookAt camera-mode only) | |
Zoom/FOV | Change the FOV of the camera | |
CamFwd (Unused) | Toggle between xyz movement relative to world coords or camera local coords and rotation (Free camera-mode only) |
Getting started
Test the project
Before I start using a plugin, I all ways like to run the examples prior to setting it up for my own project. Just to see if the plugin satisfy my needs. If you're like me then this is for you.
- Clone this repo to your local machine
- Go into the project folder (
cd bevy_config_cam
) - And run the cargo command (
cargo run --release --example simple
) - Test functionality
Player : ↑←↓→ for movement, RShift & - for going up and down.
Camera : WASD for movement, Space & LShift for going up and down.
Switch Camera: C (Look in console for which camera type you are on)
Settings: E and use the mouse-scroll to change the selected settings value.
Add to your own project
Adding this plugin to your project is very simple, it only requires you to write 2 lines of code.
Step 1. - Setup
Add the correct version to your Cargo.toml
, you can find the version you are looking for under the support section. The thing you should be adding should look like this (only add the line marked by # <--
):
[dependencies]
bevy = { version = "0.7"}
# ...
bevy_config_cam = { version = "0.3.0"} # <--
Step 2. - Add to project
fn main() {
App::new()
.insert_resource(Msaa { samples: 4 })
.add_plugins(DefaultPlugins)
.add_plugin(ConfigCam) // <--
// ...
// Your other plugins and game code here
// ...
.run();
}
Step 3. - Config (Optional)
Now, there is a reason for the name bevy_config_cam
. It is most likely that you want something more than just the default behavior. You might want to toggle between 2 types of cameras or allow the user to change the fov using a slider. Currently I haven't gotten far with creating a user-friendly api you can access but is something I will look into. For now you can insert two resources to override the default behavior of the plugin, as seen in the example:
.insert_resource(MovementSettings {
sensitivity: 0.00015, // default: 0.00012
speed: 15.0, // default: 12.0
dist: 5.0, // Camera distance from the player in topdown view
..Default::default()
})
.insert_resource(PlayerSettings {
pos: Vec3::new(2., 0., 0.),//Initial position of the player
player_asset: "models/craft_speederA.glb#Scene0", //Model of the player, default is a red cube
..Default::default()
})
Note: That some of them are overwritten by accessing the settings or the changing the camera type. Feedback on this is high appreciated, just create a new issue and I'll look into it when I have the time.
Support
bevy | bevy_config_cam |
---|---|
0.5 | 0.1.X |
0.6 | 0.2.X |
0.7 | 0.3.X |
Licensing
The project is under dual license MIT and Apache-2.0, so yoink to your hearts content, just remember the license agreements.
Contributing
Yes this project is still very much WIP, so PRs are very welcome
Dependencies
~34–48MB
~812K SLoC