Skip to content

Commit

Permalink
Support EffectiveCharacterMovement addition of is_sliding_down_slope (#…
Browse files Browse the repository at this point in the history
…353)

* Support EffectiveCharacterMovement addition of is_sliding_down_slope

---------

Co-authored-by: Thierry Berger <[email protected]>
Co-authored-by: Jeff425 <[email protected]>
  • Loading branch information
3 people authored May 20, 2024
1 parent 05b4092 commit 032bd5c
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
### Added

- Derive `Debug` for `LockedAxes`.
- Expose `is_sliding_down_slope` to both `MoveShapeOutput` and `KinematicCharacterControllerOutput`.

## v0.26.0 (05 May 2024)

Expand Down
4 changes: 4 additions & 0 deletions src/control/character_controller.rs
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,8 @@ pub struct KinematicCharacterControllerOutput {
pub effective_translation: Vect,
/// Collisions between the character and obstacles found in its path.
pub collisions: Vec<CharacterCollision>,
/// Indicates whether the shape is sliding down a slope after its kinematic movement.
pub is_sliding_down_slope: bool,
}

/// The allowed movement computed by `RapierContext::move_shape`.
Expand All @@ -225,4 +227,6 @@ pub struct MoveShapeOutput {
pub grounded: bool,
/// The translation calculated by the last character control step taking obstacles into account.
pub effective_translation: Vect,
/// Indicates whether the shape is sliding down a slope after its kinematic movement.
pub is_sliding_down_slope: bool,
}
1 change: 1 addition & 0 deletions src/plugin/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,7 @@ impl RapierContext {
MoveShapeOutput {
effective_translation: result.translation.into(),
grounded: result.grounded,
is_sliding_down_slope: result.is_sliding_down_slope,
}
}

Expand Down
2 changes: 2 additions & 0 deletions src/plugin/systems/character_controller.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ pub fn update_character_controls(
output.grounded = movement.grounded;
output.collisions.clear();
output.collisions.extend(converted_collisions);
output.is_sliding_down_slope = movement.is_sliding_down_slope;
} else {
commands
.entity(entity)
Expand All @@ -158,6 +159,7 @@ pub fn update_character_controls(
effective_translation: movement.translation.into(),
grounded: movement.grounded,
collisions: converted_collisions.collect(),
is_sliding_down_slope: movement.is_sliding_down_slope,
});
}

Expand Down

0 comments on commit 032bd5c

Please sign in to comment.