From 907adb37cee5f1b907d25069d0e0a037297f656e Mon Sep 17 00:00:00 2001 From: Marcel Admiraal Date: Wed, 15 Jan 2020 08:04:02 +0100 Subject: 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. --- scene/3d/physics_body.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'scene/3d') diff --git a/scene/3d/physics_body.cpp b/scene/3d/physics_body.cpp index 999f39c841..caeae90238 100644 --- a/scene/3d/physics_body.cpp +++ b/scene/3d/physics_body.cpp @@ -1159,7 +1159,7 @@ Vector3 KinematicBody::move_and_slide(const Vector3 &p_linear_velocity, const Ve on_ceiling = false; on_wall = false; colliders.clear(); - floor_normal = p_up_direction; + floor_normal = Vector3(); floor_velocity = Vector3(); while (p_max_slides) { @@ -1401,7 +1401,7 @@ void KinematicBody::_bind_methods() { ClassDB::bind_method(D_METHOD("move_and_collide", "rel_vec", "infinite_inertia", "exclude_raycast_shapes", "test_only"), &KinematicBody::_move, DEFVAL(true), DEFVAL(true), DEFVAL(false)); ClassDB::bind_method(D_METHOD("move_and_slide", "linear_velocity", "up_direction", "stop_on_slope", "max_slides", "floor_max_angle", "infinite_inertia"), &KinematicBody::move_and_slide, DEFVAL(Vector3(0, 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"), &KinematicBody::move_and_slide_with_snap, DEFVAL(Vector3(0, 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"), &KinematicBody::move_and_slide_with_snap, DEFVAL(Vector3(0, 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"), &KinematicBody::test_move, DEFVAL(true)); -- cgit v1.2.3