Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install alsa and udev
run: sudo apt-get update; sudo apt-get install --no-install-recommends libasound2-dev libudev-dev
# See: https://github.com/bevyengine/bevy/blob/main/docs/linux_dependencies.md
- name: Install Bevy dependencies
run: sudo apt-get update; sudo apt-get install --no-install-recommends g++ pkg-config libx11-dev libasound2-dev libudev-dev libxkbcommon-x11-0 libwayland-dev libxkbcommon-dev
- name: Build Rapier
run: cargo build --verbose --features rapier --examples
- name: Build Avian
Expand Down
8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "bevy_fps_controller"
version = "16.1.0"
version = "17.0.0"
edition = "2021"
authors = ["bevy_fps_controller"]
repository = "https://github.com/qhdwight/bevy_fps_controller"
Expand All @@ -10,9 +10,9 @@ readme = "README.md"
description = "Bevy plugin that adds a Source engine inspired FPS movement controller"

[dependencies]
bevy = "0.16"
bevy_rapier3d = { version = "0.31", optional = true }
avian3d = { version = "0.3", optional = true }
bevy = "0.17"
bevy_rapier3d = { version = "0.32", optional = true }
avian3d = { version = "0.4", optional = true }

[features]
default = []
Expand Down
31 changes: 14 additions & 17 deletions examples/minimal_avian.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ use std::f32::consts::TAU;

use avian3d::prelude::*;
use bevy::{
camera::Exposure,
gltf::{Gltf, GltfMesh, GltfNode},
math::Vec3Swizzles,
prelude::*,
render::camera::Exposure,
window::CursorGrabMode,
window::{CursorGrabMode, CursorOptions},
};

use bevy_fps_controller::controller::*;
Expand Down Expand Up @@ -70,7 +70,6 @@ fn setup(mut commands: Commands, mut window: Query<&mut Window>, assets: Res<Ass
},
LinearVelocity::ZERO,
RigidBody::Dynamic,
Sleeping,
LockedAxes::ROTATION_LOCKED,
Mass(1.0),
GravityScale(0.0),
Expand Down Expand Up @@ -178,23 +177,21 @@ fn scene_colliders(
fn manage_cursor(
btn: Res<ButtonInput<MouseButton>>,
key: Res<ButtonInput<KeyCode>>,
mut window_query: Query<&mut Window>,
mut cursor: Single<&mut CursorOptions>,
mut controller_query: Query<&mut FpsController>,
) {
for mut window in &mut window_query {
if btn.just_pressed(MouseButton::Left) {
window.cursor_options.grab_mode = CursorGrabMode::Locked;
window.cursor_options.visible = false;
for mut controller in &mut controller_query {
controller.enable_input = true;
}
if btn.just_pressed(MouseButton::Left) {
cursor.grab_mode = CursorGrabMode::Locked;
cursor.visible = false;
for mut controller in &mut controller_query {
controller.enable_input = true;
}
if key.just_pressed(KeyCode::Escape) {
window.cursor_options.grab_mode = CursorGrabMode::None;
window.cursor_options.visible = true;
for mut controller in &mut controller_query {
controller.enable_input = false;
}
}
if key.just_pressed(KeyCode::Escape) {
cursor.grab_mode = CursorGrabMode::None;
cursor.visible = true;
for mut controller in &mut controller_query {
controller.enable_input = false;
}
}
}
Expand Down
30 changes: 14 additions & 16 deletions examples/minimal_rapier.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
use std::f32::consts::TAU;

use bevy::{
camera::Exposure,
gltf::{Gltf, GltfMesh, GltfNode},
math::Vec3Swizzles,
prelude::*,
render::camera::Exposure,
window::CursorGrabMode,
window::{CursorGrabMode, CursorOptions},
};
use bevy_rapier3d::prelude::*;

Expand Down Expand Up @@ -183,23 +183,21 @@ fn scene_colliders(
fn manage_cursor(
btn: Res<ButtonInput<MouseButton>>,
key: Res<ButtonInput<KeyCode>>,
mut window_query: Query<&mut Window>,
mut cursor: Single<&mut CursorOptions>,
mut controller_query: Query<&mut FpsController>,
) {
for mut window in &mut window_query {
if btn.just_pressed(MouseButton::Left) {
window.cursor_options.grab_mode = CursorGrabMode::Locked;
window.cursor_options.visible = false;
for mut controller in &mut controller_query {
controller.enable_input = true;
}
if btn.just_pressed(MouseButton::Left) {
cursor.grab_mode = CursorGrabMode::Locked;
cursor.visible = false;
for mut controller in &mut controller_query {
controller.enable_input = true;
}
if key.just_pressed(KeyCode::Escape) {
window.cursor_options.grab_mode = CursorGrabMode::None;
window.cursor_options.visible = true;
for mut controller in &mut controller_query {
controller.enable_input = false;
}
}
if key.just_pressed(KeyCode::Escape) {
cursor.grab_mode = CursorGrabMode::None;
cursor.visible = true;
for mut controller in &mut controller_query {
controller.enable_input = false;
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/controller_avian.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ const SLIGHT_SCALE_DOWN: f32 = 0.9375;

pub fn fps_controller_input(
key_input: Res<ButtonInput<KeyCode>>,
mut mouse_events: EventReader<MouseMotion>,
mut mouse_events: MessageReader<MouseMotion>,
mut query: Query<(&FpsController, &mut FpsControllerInput)>,
) {
for (controller, mut input) in query
Expand Down
2 changes: 1 addition & 1 deletion src/controller_rapier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ const SLIGHT_SCALE_DOWN: f32 = 0.9375;

pub fn fps_controller_input(
key_input: Res<ButtonInput<KeyCode>>,
mut mouse_events: EventReader<MouseMotion>,
mut mouse_events: MessageReader<MouseMotion>,
mut query: Query<(&FpsController, &mut FpsControllerInput)>,
) {
for (controller, mut input) in query
Expand Down