diff options
Diffstat (limited to 'scene/3d')
-rw-r--r-- | scene/3d/physics_body_3d.cpp | 13 | ||||
-rw-r--r-- | scene/3d/physics_body_3d.h | 1 |
2 files changed, 12 insertions, 2 deletions
diff --git a/scene/3d/physics_body_3d.cpp b/scene/3d/physics_body_3d.cpp index c8cfcf7d7a..ab5b054bb3 100644 --- a/scene/3d/physics_body_3d.cpp +++ b/scene/3d/physics_body_3d.cpp @@ -1565,8 +1565,8 @@ void CharacterBody3D::_move_and_slide_floating(double p_delta) { } } -void CharacterBody3D::_snap_on_floor(bool p_was_on_floor, bool p_vel_dir_facing_up) { - if (collision_state.floor || !p_was_on_floor || p_vel_dir_facing_up) { +void CharacterBody3D::apply_floor_snap() { + if (collision_state.floor) { return; } @@ -1601,6 +1601,14 @@ void CharacterBody3D::_snap_on_floor(bool p_was_on_floor, bool p_vel_dir_facing_ } } +void CharacterBody3D::_snap_on_floor(bool p_was_on_floor, bool p_vel_dir_facing_up) { + if (collision_state.floor || !p_was_on_floor || p_vel_dir_facing_up) { + return; + } + + apply_floor_snap(); +} + bool CharacterBody3D::_on_floor_if_snapped(bool p_was_on_floor, bool p_vel_dir_facing_up) { if (up_direction == Vector3() || collision_state.floor || !p_was_on_floor || p_vel_dir_facing_up) { return false; @@ -1954,6 +1962,7 @@ void CharacterBody3D::_notification(int p_what) { void CharacterBody3D::_bind_methods() { ClassDB::bind_method(D_METHOD("move_and_slide"), &CharacterBody3D::move_and_slide); + ClassDB::bind_method(D_METHOD("apply_floor_snap"), &CharacterBody3D::apply_floor_snap); ClassDB::bind_method(D_METHOD("set_velocity", "velocity"), &CharacterBody3D::set_velocity); ClassDB::bind_method(D_METHOD("get_velocity"), &CharacterBody3D::get_velocity); diff --git a/scene/3d/physics_body_3d.h b/scene/3d/physics_body_3d.h index 92d4726bb5..d141c1aaa2 100644 --- a/scene/3d/physics_body_3d.h +++ b/scene/3d/physics_body_3d.h @@ -354,6 +354,7 @@ public: PLATFORM_ON_LEAVE_DO_NOTHING, }; bool move_and_slide(); + void apply_floor_snap(); const Vector3 &get_velocity() const; void set_velocity(const Vector3 &p_velocity); |