summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2018-11-12 21:14:15 +0100
committerGitHub <noreply@github.com>2018-11-12 21:14:15 +0100
commit193d695a1a8a179f5f5d6a2aff660696197eb0a0 (patch)
tree2605cad94efd0678a260b82d11715293f87d693a
parent3bc7dfc8568d2cf02876f1ad29ea5af0696bbeb2 (diff)
parentd94c76a19930a4f6f83ad56b38b41eaa563f9571 (diff)
Merge pull request #17530 from bojidar-bg/17516-detect-delta
Make it possible to call move_and_slide from _process, even if it is not recommended
-rw-r--r--scene/2d/physics_body_2d.cpp3
-rw-r--r--scene/3d/physics_body.cpp3
2 files changed, 4 insertions, 2 deletions
diff --git a/scene/2d/physics_body_2d.cpp b/scene/2d/physics_body_2d.cpp
index 4a01644c5b..929b4624ee 100644
--- a/scene/2d/physics_body_2d.cpp
+++ b/scene/2d/physics_body_2d.cpp
@@ -1237,7 +1237,8 @@ Vector2 KinematicBody2D::move_and_slide(const Vector2 &p_linear_velocity, const
}
}
- Vector2 motion = (floor_motion + p_linear_velocity) * get_physics_process_delta_time();
+ // Hack in order to work with calling from _process as well as from _physics_process; calling from thread is risky
+ Vector2 motion = (floor_motion + p_linear_velocity) * (Engine::get_singleton()->is_in_physics_frame() ? get_physics_process_delta_time() : get_process_delta_time());
Vector2 lv = p_linear_velocity;
on_floor = false;
diff --git a/scene/3d/physics_body.cpp b/scene/3d/physics_body.cpp
index d18986739e..9148b436a0 100644
--- a/scene/3d/physics_body.cpp
+++ b/scene/3d/physics_body.cpp
@@ -1167,7 +1167,8 @@ Vector3 KinematicBody::move_and_slide(const Vector3 &p_linear_velocity, const Ve
}
}
- Vector3 motion = (floor_velocity + lv) * get_physics_process_delta_time();
+ // Hack in order to work with calling from _process as well as from _physics_process; calling from thread is risky
+ Vector3 motion = (floor_velocity + lv) * (Engine::get_singleton()->is_in_physics_frame() ? get_physics_process_delta_time() : get_process_delta_time());
on_floor = false;
on_ceiling = false;