From bf9d9712153c468c391772f9c2562cfe5ee6a2b2 Mon Sep 17 00:00:00 2001 From: kobewi Date: Sun, 10 Sep 2023 22:18:34 +0200 Subject: [PATCH] Check if property exists before tweening --- scene/animation/tween.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/scene/animation/tween.cpp b/scene/animation/tween.cpp index 1b8c4101012..1cc29fd1f25 100644 --- a/scene/animation/tween.cpp +++ b/scene/animation/tween.cpp @@ -104,7 +104,15 @@ Ref Tween::tween_property(const Object *p_target, const NodePat CHECK_VALID(); Vector property_subnames = p_property.get_as_property_path().get_subnames(); - if (!_validate_type_match(p_target->get_indexed(property_subnames), p_to)) { +#ifdef DEBUG_ENABLED + bool prop_valid; + const Variant &prop_value = p_target->get_indexed(property_subnames, &prop_valid); + ERR_FAIL_COND_V_MSG(!prop_valid, nullptr, vformat("The tweened property \"%s\" does not exist in object \"%s\".", p_property, p_target)); +#else + const Variant &prop_value = p_target->get_indexed(property_subnames); +#endif + + if (!_validate_type_match(prop_value, p_to)) { return nullptr; }