From eb9157df23f7141c270737af8e0a503c6c281e15 Mon Sep 17 00:00:00 2001 From: Ricardo Buring Date: Sun, 17 Apr 2022 17:26:05 +0200 Subject: [PATCH] PathFollow2D and PathFollow3D: don't set offset to NaN --- scene/2d/path_2d.cpp | 2 +- scene/3d/path_3d.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/scene/2d/path_2d.cpp b/scene/2d/path_2d.cpp index aa68349329a..a21cb7db623 100644 --- a/scene/2d/path_2d.cpp +++ b/scene/2d/path_2d.cpp @@ -311,7 +311,7 @@ void PathFollow2D::set_offset(real_t p_offset) { if (path->get_curve().is_valid()) { real_t path_length = path->get_curve()->get_baked_length(); - if (loop) { + if (loop && path_length) { offset = Math::fposmod(offset, path_length); if (!Math::is_zero_approx(p_offset) && Math::is_zero_approx(offset)) { offset = path_length; diff --git a/scene/3d/path_3d.cpp b/scene/3d/path_3d.cpp index 7a5cb26a292..49811250571 100644 --- a/scene/3d/path_3d.cpp +++ b/scene/3d/path_3d.cpp @@ -310,7 +310,7 @@ void PathFollow3D::set_offset(real_t p_offset) { if (path->get_curve().is_valid()) { real_t path_length = path->get_curve()->get_baked_length(); - if (loop) { + if (loop && path_length) { offset = Math::fposmod(offset, path_length); if (!Math::is_zero_approx(p_offset) && Math::is_zero_approx(offset)) { offset = path_length;