Skip to content

Commit 16cfc13

Browse files
committed
fix character capsule size issue.
In project Foxtrot, the capsule of the fox should be in fact a lying down cylinder. Because its an quadruped animal. So in fact in the code the height is the length of the fox, and the radius is a half of the height of the fox. Also, the radius of the capsule need to be multiplied by the scale_y.
1 parent d3b772e commit 16cfc13

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

src/movement/character_controller/components.rs

+3-8
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use crate::movement::{character_controller::AnimationState, physics::CollisionLa
22
use bevy::prelude::*;
33
use bevy_tnua::{prelude::*, TnuaAnimatingState};
44
use bevy_tnua_xpbd3d::*;
5-
use bevy_xpbd_3d::prelude::*;
5+
use bevy_xpbd_3d::{parry::shape::SharedShape, prelude::*};
66
use serde::{Deserialize, Serialize};
77

88
pub(super) fn plugin(app: &mut App) {
@@ -30,8 +30,7 @@ impl CharacterControllerBundle {
3030
walking: default(),
3131
sprinting: default(),
3232
jumping: default(),
33-
collider: bevy_xpbd_3d::parry::shape::SharedShape::capsule_z(height, radius * scale_y)
34-
.into(),
33+
collider: SharedShape::capsule_z(height, radius * scale_y).into(),
3534
rigid_body: RigidBody::Dynamic,
3635
locked_axes: LockedAxes::new().lock_rotation_x().lock_rotation_z(),
3736
collision_layers: CollisionLayers::new(
@@ -44,11 +43,7 @@ impl CharacterControllerBundle {
4443
],
4544
),
4645
tnua_sensor_shape: TnuaXpbd3dSensorShape(
47-
bevy_xpbd_3d::parry::shape::SharedShape::capsule_z(
48-
height * 0.95,
49-
radius * scale_y * 0.95,
50-
)
51-
.into(),
46+
SharedShape::capsule_z(height * 0.95, radius * scale_y * 0.95).into(),
5247
),
5348
tnua_controller: default(),
5449
float_height: FloatHeight(radius * scale_y),

0 commit comments

Comments
 (0)