diff options
author | Marcel Admiraal <madmiraal@users.noreply.github.com> | 2020-01-15 08:04:02 +0100 |
---|---|---|
committer | Marcel Admiraal <madmiraal@users.noreply.github.com> | 2020-01-15 10:13:35 +0100 |
commit | 907adb37cee5f1b907d25069d0e0a037297f656e (patch) | |
tree | 9572c61bc022f636fbfbbca9f250ca3f866e1985 /scene/2d/physics_body_2d.cpp | |
parent | 40f0649e5b02037cb4745c336170e1e5422467ed (diff) |
Fixes get_floor_normal() returning the user defined floor_normal.
When there is no collision with a floor the get_floor_normal() function
should return the zero vector to be consistent with get_floor_velocity().
Renames floor_normal to up_direction in all bindings.
Updates the documentation of get_floor_normal() and get_floor_velocity()
to make it clear when the values are valid. Updates the documentation for
move_and_slide() and move_and_slide_with_snap() to use the new up_direction
parameter name.
Diffstat (limited to 'scene/2d/physics_body_2d.cpp')
-rw-r--r-- | scene/2d/physics_body_2d.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/scene/2d/physics_body_2d.cpp b/scene/2d/physics_body_2d.cpp index 90663bd675..d42bd6adaf 100644 --- a/scene/2d/physics_body_2d.cpp +++ b/scene/2d/physics_body_2d.cpp @@ -1234,7 +1234,7 @@ Vector2 KinematicBody2D::move_and_slide(const Vector2 &p_linear_velocity, const on_ceiling = false; on_wall = false; colliders.clear(); - floor_normal = p_up_direction; + floor_normal = Vector2(); floor_velocity = Vector2(); while (p_max_slides) { @@ -1473,8 +1473,8 @@ void KinematicBody2D::_notification(int p_what) { void KinematicBody2D::_bind_methods() { ClassDB::bind_method(D_METHOD("move_and_collide", "rel_vec", "infinite_inertia", "exclude_raycast_shapes", "test_only"), &KinematicBody2D::_move, DEFVAL(true), DEFVAL(true), DEFVAL(false)); - ClassDB::bind_method(D_METHOD("move_and_slide", "linear_velocity", "floor_normal", "stop_on_slope", "max_slides", "floor_max_angle", "infinite_inertia"), &KinematicBody2D::move_and_slide, DEFVAL(Vector2(0, 0)), DEFVAL(false), DEFVAL(4), DEFVAL(Math::deg2rad((float)45)), DEFVAL(true)); - ClassDB::bind_method(D_METHOD("move_and_slide_with_snap", "linear_velocity", "snap", "floor_normal", "stop_on_slope", "max_slides", "floor_max_angle", "infinite_inertia"), &KinematicBody2D::move_and_slide_with_snap, DEFVAL(Vector2(0, 0)), DEFVAL(false), DEFVAL(4), DEFVAL(Math::deg2rad((float)45)), DEFVAL(true)); + ClassDB::bind_method(D_METHOD("move_and_slide", "linear_velocity", "up_direction", "stop_on_slope", "max_slides", "floor_max_angle", "infinite_inertia"), &KinematicBody2D::move_and_slide, DEFVAL(Vector2(0, 0)), DEFVAL(false), DEFVAL(4), DEFVAL(Math::deg2rad((float)45)), DEFVAL(true)); + ClassDB::bind_method(D_METHOD("move_and_slide_with_snap", "linear_velocity", "snap", "up_direction", "stop_on_slope", "max_slides", "floor_max_angle", "infinite_inertia"), &KinematicBody2D::move_and_slide_with_snap, DEFVAL(Vector2(0, 0)), DEFVAL(false), DEFVAL(4), DEFVAL(Math::deg2rad((float)45)), DEFVAL(true)); ClassDB::bind_method(D_METHOD("test_move", "from", "rel_vec", "infinite_inertia"), &KinematicBody2D::test_move, DEFVAL(true)); |