diff options
author | RĂ©mi Verschelde <remi@verschelde.fr> | 2022-08-30 15:53:04 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-30 15:53:04 +0200 |
commit | f58d864f867902e8650f428dc75d5bbb0b874727 (patch) | |
tree | 65f299abcc9c8ebc43f4a2a695dab69a6d17345c /scene | |
parent | ac053bb72dbe60f9bf43a3002e7331cd4ab28adb (diff) | |
parent | 2b18a4002c8e500597bc8f5d605f9be8d1b22236 (diff) |
Merge pull request #65072 from Mickeon/try-tween-float-cast
Diffstat (limited to 'scene')
-rw-r--r-- | scene/animation/tween.cpp | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/scene/animation/tween.cpp b/scene/animation/tween.cpp index 7d9f83b7a2..5b18d4e457 100644 --- a/scene/animation/tween.cpp +++ b/scene/animation/tween.cpp @@ -75,10 +75,17 @@ Ref<PropertyTweener> Tween::tween_property(Object *p_target, NodePath p_property ERR_FAIL_COND_V_MSG(!valid, nullptr, "Tween invalid. Either finished or created outside scene tree."); ERR_FAIL_COND_V_MSG(started, nullptr, "Can't append to a Tween that has started. Use stop() first."); -#ifdef DEBUG_ENABLED Variant::Type property_type = p_target->get_indexed(p_property.get_as_property_path().get_subnames()).get_type(); - ERR_FAIL_COND_V_MSG(property_type != p_to.get_type(), Ref<PropertyTweener>(), "Type mismatch between property and final value: " + Variant::get_type_name(property_type) + " and " + Variant::get_type_name(p_to.get_type())); -#endif + if (property_type != p_to.get_type()) { + // Cast p_to between floats and ints to avoid minor annoyances. + if (property_type == Variant::FLOAT && p_to.get_type() == Variant::INT) { + p_to = float(p_to); + } else if (property_type == Variant::INT && p_to.get_type() == Variant::FLOAT) { + p_to = int(p_to); + } else { + ERR_FAIL_V_MSG(Ref<PropertyTweener>(), "Type mismatch between property and final value: " + Variant::get_type_name(property_type) + " and " + Variant::get_type_name(p_to.get_type())); + } + } Ref<PropertyTweener> tweener = memnew(PropertyTweener(p_target, p_property, p_to, p_duration)); append(tweener); |