Skip to content

Commit 2ef1e9a

Browse files
committed
Drop rapier3d in favour of avian3d
1 parent 3b292e4 commit 2ef1e9a

5 files changed

Lines changed: 136 additions & 71 deletions

File tree

Cargo.lock

Lines changed: 122 additions & 53 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ bevy_asset = "0.17.3"
1313
bevy_camera = "0.17.3"
1414
bevy_mesh = "0.17.3"
1515
bevy_dev_tools = "0.17.3"
16-
bevy_fps_controller = {version = "17.1.0", features = ["rapier"]}
17-
bevy_rapier3d = {version ="0.32"}
16+
bevy_fps_controller = {version = "17.1.0", features = ["avian"]}
17+
avian3d = {version="0.4", features = ["debug-plugin"]}
1818
bevy_flair = "0.6.0"
1919
bevy_egui = { version = "0.38.1", features = ["immutable_ctx"]}
2020
bevy_diagnostic = "0.17.3"

src/client/player/mod.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ pub mod resources;
44
pub mod systems;
55

66
use crate::prelude::*;
7+
use avian3d::PhysicsPlugins;
78

89
pub struct PlayerPlugin;
910

@@ -12,9 +13,9 @@ impl Plugin for PlayerPlugin {
1213
debug!("Building PlayerPlugin");
1314
info!("Building PlayerPlugin");
1415
app.add_plugins(FpsControllerPlugin);
15-
app.add_plugins(RapierPhysicsPlugin::<NoUserData>::default());
16+
app.add_plugins(PhysicsPlugins::default());
1617
#[cfg(feature = "physics_debug")]
17-
app.add_plugins(RapierDebugRenderPlugin::default());
18+
app.add_plugins(PhysicsDebugPlugin::default());
1819
app.add_message::<player_events::PlayerColliderUpdateEvent>();
1920
app.insert_resource(player_resources::BlockSelection::new());
2021
app.insert_resource(player_resources::PlayerSpawned(false));

src/client/player/systems/controller.rs

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,26 +36,24 @@ pub fn setup_controller_on_area_ready_system(
3636

3737
let logical_entity = commands
3838
.spawn((
39-
Collider::capsule(Vec3::Y * 0.5, Vec3::Y * 1.5, 0.5),
39+
Collider::cylinder(0.5, 1.5),
4040
Friction {
41-
coefficient: 0.0,
42-
combine_rule: CoefficientCombineRule::Min,
41+
dynamic_coefficient: 0.0,
42+
static_coefficient: 0.0,
43+
combine_rule: CoefficientCombine::Min,
4344
},
4445
Restitution {
4546
coefficient: 0.0,
46-
combine_rule: CoefficientCombineRule::Min,
47+
combine_rule: CoefficientCombine::Min,
4748
},
48-
ActiveEvents::COLLISION_EVENTS,
49-
Velocity::zero(),
49+
LinearVelocity::ZERO,
5050
#[cfg(feature = "lock_player")]
51-
RigidBody::Fixed,
51+
RigidBody::Static,
5252
#[cfg(not(feature = "lock_player"))]
5353
RigidBody::Dynamic,
54-
Sleeping::disabled(),
5554
LockedAxes::ROTATION_LOCKED,
56-
AdditionalMassProperties::Mass(1.0),
55+
Mass(1.0),
5756
GravityScale(0.0),
58-
Ccd { enabled: true },
5957
Transform::from_translation(spawn_position),
6058
LogicalPlayer,
6159
#[cfg(not(feature = "lock_player"))]

src/client/prelude.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,9 @@ pub use bevy::prelude::*;
1414
pub use bevy::transform::components::Transform;
1515
pub use bevy::window::*;
1616

17+
pub use avian3d::prelude::*;
1718
pub use bevy_fps_controller::controller::*;
1819

19-
pub use bevy_rapier3d::geometry::Collider;
20-
pub use bevy_rapier3d::{dynamics::*, geometry::*};
21-
pub use bevy_rapier3d::{plugin::*, render::RapierDebugRenderPlugin};
22-
2320
// networking crates
2421
pub use renet::{ClientId, ConnectionConfig, DefaultChannel, RenetClient};
2522

0 commit comments

Comments
 (0)