Allow BTPlayAnimation with `animation_name` empty to resume playback after pause
This commit is contained in:
parent
8e3c4c7570
commit
94f6d289a8
|
@ -65,18 +65,16 @@ String BTPlayAnimation::get_configuration_warning() const {
|
||||||
warning += "AnimationPlayer blackboard variable is not set.\n";
|
warning += "AnimationPlayer blackboard variable is not set.\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (animation_name == StringName()) {
|
if (animation_name == StringName() && await_completion > 0.0) {
|
||||||
warning += "Animation Name is not set.\n";
|
warning += "Animation Name is required in order to wait for the animation to finish.\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
return warning;
|
return warning;
|
||||||
}
|
}
|
||||||
|
|
||||||
String BTPlayAnimation::_generate_name() const {
|
String BTPlayAnimation::_generate_name() const {
|
||||||
if (animation_name == StringName() || animation_player_param.is_null()) {
|
return "PlayAnimation" +
|
||||||
return "PlayAnimation ???";
|
(animation_name != StringName() ? vformat(" \"%s\"", animation_name) : "") +
|
||||||
}
|
|
||||||
return vformat("PlayAnimation \"%s\"", animation_name) +
|
|
||||||
(blend >= 0.0 ? vformat(" blend: %ss", Math::snapped(blend, 0.001)) : "") +
|
(blend >= 0.0 ? vformat(" blend: %ss", Math::snapped(blend, 0.001)) : "") +
|
||||||
(speed != 1.0 ? vformat(" speed: %s", Math::snapped(speed, 0.001)) : "") +
|
(speed != 1.0 ? vformat(" speed: %s", Math::snapped(speed, 0.001)) : "") +
|
||||||
(from_end != false ? vformat(" from_end: %s", from_end) : "") +
|
(from_end != false ? vformat(" from_end: %s", from_end) : "") +
|
||||||
|
@ -88,8 +86,10 @@ void BTPlayAnimation::_setup() {
|
||||||
ERR_FAIL_COND_MSG(animation_player_param.is_null(), "BTPlayAnimation: AnimationPlayer parameter is not set.");
|
ERR_FAIL_COND_MSG(animation_player_param.is_null(), "BTPlayAnimation: AnimationPlayer parameter is not set.");
|
||||||
animation_player = Object::cast_to<AnimationPlayer>(animation_player_param->get_value(get_agent(), get_blackboard()));
|
animation_player = Object::cast_to<AnimationPlayer>(animation_player_param->get_value(get_agent(), get_blackboard()));
|
||||||
ERR_FAIL_COND_MSG(animation_player == nullptr, "BTPlayAnimation: Failed to get AnimationPlayer.");
|
ERR_FAIL_COND_MSG(animation_player == nullptr, "BTPlayAnimation: Failed to get AnimationPlayer.");
|
||||||
ERR_FAIL_COND_MSG(animation_name == StringName(), "BTPlayAnimation: Animation name is not set.");
|
ERR_FAIL_COND_MSG(animation_name != StringName() && !animation_player->has_animation(animation_name), vformat("BTPlayAnimation: Animation not found: %s", animation_name));
|
||||||
ERR_FAIL_COND_MSG(!animation_player->has_animation(animation_name), vformat("BTPlayAnimation: Animation not found: %s", animation_name));
|
if (animation_name == StringName() && await_completion > 0.0) {
|
||||||
|
WARN_PRINT("BTPlayAnimation: Animation Name is required in order to wait for the animation to finish.");
|
||||||
|
}
|
||||||
setup_failed = false;
|
setup_failed = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
</tutorials>
|
</tutorials>
|
||||||
<members>
|
<members>
|
||||||
<member name="animation_name" type="StringName" setter="set_animation_name" getter="get_animation_name" default="&""">
|
<member name="animation_name" type="StringName" setter="set_animation_name" getter="get_animation_name" default="&""">
|
||||||
Animation's key within the AnimationPlayer node.
|
Animation's key within the AnimationPlayer node. If empty, BTPlayAnimation will resume the last played animation if [class AnimationPlayer] was paused.
|
||||||
</member>
|
</member>
|
||||||
<member name="animation_player" type="BBNode" setter="set_animation_player" getter="get_animation_player">
|
<member name="animation_player" type="BBNode" setter="set_animation_player" getter="get_animation_player">
|
||||||
Parameter that specifies the AnimationPlayer node.
|
Parameter that specifies the AnimationPlayer node.
|
||||||
|
|
Loading…
Reference in New Issue