Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/liamgallagher737/bevy_arcade_car_controller
A simple arcade car controller for Bevy
https://github.com/liamgallagher737/bevy_arcade_car_controller
bevy bevy-engine rust
Last synced: 3 months ago
JSON representation
A simple arcade car controller for Bevy
- Host: GitHub
- URL: https://github.com/liamgallagher737/bevy_arcade_car_controller
- Owner: LiamGallagher737
- License: apache-2.0
- Archived: true
- Created: 2022-07-23T01:42:32.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2022-07-25T10:32:34.000Z (over 2 years ago)
- Last Synced: 2024-09-26T07:04:13.525Z (3 months ago)
- Topics: bevy, bevy-engine, rust
- Language: Rust
- Homepage: https://crates.io/crates/bevy_arcade_car_controller
- Size: 17.6 KB
- Stars: 1
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE-APACHE
Awesome Lists containing this project
README
# Arcade Car Controller
A simple arcade car controller for [Bevy](https://bevyengine.org/)
## How to use
`Cargo.toml`
```toml
bevy ="0.7"
bevy_arcade_car_controller = "0.1.0"
heron = { version = "3.1", features = ["3d"] }
````main.rs`
```rs
use bevy::prelude::*;
use bevy_arcade_car_controller::*;
use heron::prelude::*;fn main() {
App::new()
// Plugins
.add_plugins(DefaultPlugins)
.add_plugin(ArcadeCarControllerPlugin)
// Systems
.add_startup_system(startup_system)
.add_system(drive_system)
.run();
}fn startup_system(
mut commands: Commands,
) {
// Your car model
let car_entity = commands.spawn()
// Add Mesh, PbrBundle etc.
.insert(ArcadeCar)
.id();
// The car motor
commands.spawn_bundle(ArcadeCarBundle::new(car_entity, position, size, speed, turn_speed));
// Spawn camera, lights etc.
}fn drive_system(
mut query: Query<&mut ArcadeCarInput>,
keys: Res>
) {
// This assumes you only have one car being controlled by the player,
// If you have multiple do a for loop here instead.
if let Ok(mut input) = query.get_single_mut() {
input.reset();
if keys.pressed(KeyCode::W) {
input.acceleration += 1.0;
}
if keys.pressed(KeyCode::S) {
input.acceleration -= 0.5;
}
if keys.pressed(KeyCode::A) {
input.turn += 1.0;
}
if keys.pressed(KeyCode::D) {
input.turn -= 1.0;
}
// Not implemented yet
// if keys.pressed(KeyCode::Space) {
// input.handbrake = true;
// }
}
}
```