summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRicardo Buring <ricardo.buring@gmail.com>2022-04-17 17:26:05 +0200
committerRicardo Buring <ricardo.buring@gmail.com>2022-04-17 17:26:05 +0200
commiteb9157df23f7141c270737af8e0a503c6c281e15 (patch)
tree823655896ca732836cbe311352f5134f34f72d96
parent690fefe43ee74c0ae3ed5642f3aefbeb711f9d1c (diff)
PathFollow2D and PathFollow3D: don't set offset to NaN
-rw-r--r--scene/2d/path_2d.cpp2
-rw-r--r--scene/3d/path_3d.cpp2
2 files changed, 2 insertions, 2 deletions
diff --git a/scene/2d/path_2d.cpp b/scene/2d/path_2d.cpp
index aa68349329..a21cb7db62 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 7a5cb26a29..4981125057 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;