Closed HugoPeters1024 closed 10 months ago
Tnua, by default, casts a ray to determine the ground proximity. When you reach the end of a platform (the plane, in this case), this can be a problem because the ray can be outside the platform while part of the character is still above the platform.
To fix this, you need to cast a shape instead of a ray. In your case, the simplest way to do this is to add: this component to the cube:
TnuaRapier3dSensorShape(Collider::cuboid(0.5, 0.0, 0.5)),
Perfect, that's it! Thank you <3
First of all, thanks for making this library! This is the nicest 3d character controller for Bevy that I've found.
When my cube character reaches the end of its plane it start almost refuse to move (making walking off the edge quite hard). Also jumping commands are ignored while in this state.
At first I thought it was because I only provide an xz vector as the
desired_velocity
to theTnuaBuiltinWalk
struct. But even if I propagate the currentVelocity::linvel
(clamping the xz components to some MAX_SPEED), the issue persists.Locking the rotation by adding the
LockedAxes::ROTATION_LOCKED
to the player seemingly also has no effect on the issue.Did I miss another effect/setting, is there a known workaround?
Backend Rapier:
Screenshot:
Actually, the code is just a single file at this point, so I might as well include it here:
Full code
```rust use bevy::prelude::*; use bevy_rapier3d::prelude::*; use bevy_tnua::{ builtins::{TnuaBuiltinJump, TnuaBuiltinWalk}, controller::{TnuaController, TnuaControllerBundle, TnuaControllerPlugin}, }; use bevy_tnua_rapier3d::{TnuaRapier3dIOBundle, TnuaRapier3dPlugin}; #[derive(Component)] struct Player; #[derive(Component)] struct MainCamera; fn main() { let mut app = App::new(); app.add_plugins(DefaultPlugins); app.add_systems(Startup, setup); app.add_systems(Update, player_controls); app.add_systems(Update, camera_follow_player); app.add_plugins(RapierPhysicsPlugin::