Fix #54298 where a CharacterBody2D can be stuck on the wall.
This commit is contained in:
parent
8c162f4a7b
commit
ee3e43c853
@ -1101,7 +1101,7 @@ bool CharacterBody2D::move_and_slide() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (motion_mode == MOTION_MODE_GROUNDED) {
|
if (motion_mode == MOTION_MODE_GROUNDED) {
|
||||||
_move_and_slide_grounded(delta, was_on_floor, current_platform_velocity);
|
_move_and_slide_grounded(delta, was_on_floor);
|
||||||
} else {
|
} else {
|
||||||
_move_and_slide_free(delta);
|
_move_and_slide_free(delta);
|
||||||
}
|
}
|
||||||
@ -1122,14 +1122,11 @@ bool CharacterBody2D::move_and_slide() {
|
|||||||
return motion_results.size() > 0;
|
return motion_results.size() > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CharacterBody2D::_move_and_slide_grounded(double p_delta, bool p_was_on_floor, const Vector2 &p_prev_platform_velocity) {
|
void CharacterBody2D::_move_and_slide_grounded(double p_delta, bool p_was_on_floor) {
|
||||||
Vector2 motion = motion_velocity * p_delta;
|
Vector2 motion = motion_velocity * p_delta;
|
||||||
Vector2 motion_slide_up = motion.slide(up_direction);
|
Vector2 motion_slide_up = motion.slide(up_direction);
|
||||||
|
|
||||||
Vector2 prev_floor_normal = floor_normal;
|
Vector2 prev_floor_normal = floor_normal;
|
||||||
RID prev_platform_rid = platform_rid;
|
|
||||||
ObjectID prev_platform_object_id = platform_object_id;
|
|
||||||
int prev_platform_layer = platform_layer;
|
|
||||||
|
|
||||||
platform_rid = RID();
|
platform_rid = RID();
|
||||||
platform_object_id = ObjectID();
|
platform_object_id = ObjectID();
|
||||||
@ -1202,12 +1199,8 @@ void CharacterBody2D::_move_and_slide_grounded(double p_delta, bool p_was_on_flo
|
|||||||
gt.elements[2] -= result.travel;
|
gt.elements[2] -= result.travel;
|
||||||
set_global_transform(gt);
|
set_global_transform(gt);
|
||||||
}
|
}
|
||||||
on_floor = true;
|
// Determines if you are on the ground.
|
||||||
platform_rid = prev_platform_rid;
|
_snap_on_floor(true, false);
|
||||||
platform_object_id = prev_platform_object_id;
|
|
||||||
platform_layer = prev_platform_layer;
|
|
||||||
platform_velocity = p_prev_platform_velocity;
|
|
||||||
floor_normal = prev_floor_normal;
|
|
||||||
motion_velocity = Vector2();
|
motion_velocity = Vector2();
|
||||||
last_motion = Vector2();
|
last_motion = Vector2();
|
||||||
motion = Vector2();
|
motion = Vector2();
|
||||||
|
@ -416,7 +416,7 @@ private:
|
|||||||
MovingPlatformApplyVelocityOnLeave get_moving_platform_apply_velocity_on_leave() const;
|
MovingPlatformApplyVelocityOnLeave get_moving_platform_apply_velocity_on_leave() const;
|
||||||
|
|
||||||
void _move_and_slide_free(double p_delta);
|
void _move_and_slide_free(double p_delta);
|
||||||
void _move_and_slide_grounded(double p_delta, bool p_was_on_floor, const Vector2 &p_prev_platform_velocity);
|
void _move_and_slide_grounded(double p_delta, bool p_was_on_floor);
|
||||||
|
|
||||||
Ref<KinematicCollision2D> _get_slide_collision(int p_bounce);
|
Ref<KinematicCollision2D> _get_slide_collision(int p_bounce);
|
||||||
Ref<KinematicCollision2D> _get_last_slide_collision();
|
Ref<KinematicCollision2D> _get_last_slide_collision();
|
||||||
|
Loading…
Reference in New Issue
Block a user