diff --git a/editor/import_dock.cpp b/editor/import_dock.cpp index 1b6246e0866..40cf02ac9d0 100644 --- a/editor/import_dock.cpp +++ b/editor/import_dock.cpp @@ -424,7 +424,7 @@ void ImportDock::_reimport_attempt() { void ImportDock::_reimport_and_restart() { EditorNode::get_singleton()->save_all_scenes(); - EditorResourcePreview::get_singleton()->stop(); //dont try to re-create previews + EditorResourcePreview::get_singleton()->stop(); //dont try to re-create previews after import _reimport(); EditorNode::get_singleton()->restart_editor(); } diff --git a/scene/animation/animation_blend_tree.cpp b/scene/animation/animation_blend_tree.cpp index a343a4f0ed4..0daa574f727 100644 --- a/scene/animation/animation_blend_tree.cpp +++ b/scene/animation/animation_blend_tree.cpp @@ -141,10 +141,14 @@ void AnimationNodeOneShot::get_parameter_list(List *r_list) const r_list->push_back(PropertyInfo(Variant::BOOL, prev_active, PROPERTY_HINT_NONE, "", 0)); r_list->push_back(PropertyInfo(Variant::REAL, time, PROPERTY_HINT_NONE, "", 0)); r_list->push_back(PropertyInfo(Variant::REAL, remaining, PROPERTY_HINT_NONE, "", 0)); + r_list->push_back(PropertyInfo(Variant::REAL, time_to_restart, PROPERTY_HINT_NONE, "", 0)); } + Variant AnimationNodeOneShot::get_parameter_default_value(const StringName &p_parameter) const { if (p_parameter == active || p_parameter == prev_active) { return false; + } else if (p_parameter == time_to_restart) { + return -1; } else { return 0.0; } @@ -218,13 +222,26 @@ float AnimationNodeOneShot::process(float p_time, bool p_seek) { bool prev_active = get_parameter(this->prev_active); float time = get_parameter(this->time); float remaining = get_parameter(this->remaining); + float time_to_restart = get_parameter(this->time_to_restart); if (!active) { //make it as if this node doesn't exist, pass input 0 by. if (prev_active) { set_parameter(this->prev_active, false); } - return blend_input(0, p_time, p_seek, 1.0, FILTER_IGNORE, !sync); + if (time_to_restart >= 0.0 && !p_seek) { + time_to_restart -= p_time; + if (time_to_restart < 0) { + //restart + set_parameter(this->active, true); + active = true; + } + set_parameter(this->time_to_restart, time_to_restart); + } + + if (!active) { + return blend_input(0, p_time, p_seek, 1.0, FILTER_IGNORE, !sync); + } } bool os_seek = p_seek; @@ -276,6 +293,10 @@ float AnimationNodeOneShot::process(float p_time, bool p_seek) { if (remaining <= 0) { set_parameter(this->active, false); set_parameter(this->prev_active, false); + if (autorestart) { + float restart_sec = autorestart_delay + Math::randf() * autorestart_random_delay; + set_parameter(this->time_to_restart, restart_sec); + } } } @@ -350,6 +371,7 @@ AnimationNodeOneShot::AnimationNodeOneShot() { prev_active = "prev_active"; time = "time"; remaining = "remaining"; + time_to_restart = "time_to_restart"; } //////////////////////////////////////////////// diff --git a/scene/animation/animation_blend_tree.h b/scene/animation/animation_blend_tree.h index e2077131345..c16dcb1b8c4 100644 --- a/scene/animation/animation_blend_tree.h +++ b/scene/animation/animation_blend_tree.h @@ -91,6 +91,7 @@ private: StringName prev_active; StringName time; StringName remaining; + StringName time_to_restart; protected: static void _bind_methods();