diff options
author | Bojidar Marinov <bojidar.marinov.bg@gmail.com> | 2018-03-15 14:29:22 +0200 |
---|---|---|
committer | Bojidar Marinov <bojidar.marinov.bg@gmail.com> | 2018-11-08 20:34:34 +0200 |
commit | d94c76a19930a4f6f83ad56b38b41eaa563f9571 (patch) | |
tree | 4603ccffc07885b920416b8cd90f44f358fc374f /scene/2d | |
parent | d403b4086c514647bba7620591061b7de7dfaf4b (diff) |
Make it possible to call move_and_slide from _process, even if it is not recommended
Previously, it would reuse the _physics_process delta, causing it to move faster on faster framerates
Fixes #17516
Diffstat (limited to 'scene/2d')
-rw-r--r-- | scene/2d/physics_body_2d.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/scene/2d/physics_body_2d.cpp b/scene/2d/physics_body_2d.cpp index 33c5fef151..761a2002ee 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; |