-
-
Notifications
You must be signed in to change notification settings - Fork 103
Description
Describe the project you are working on
3D sandbox adventure game with UGC
Describe the problem or limitation you are having in your project
I have characters with nearly 100 animations, and that will expand to more in the future. I also will support UGC where users can upload their own animations to existing characters.
I'd like to simplify my animation graphs to not require every possible animation to be added to the graph as a separate node. Many animations fill similar niches that in theory don't require explicit alternative nodes in the animation tree.
This would help:
- Simplify creating AnimationTrees - create a node per animation niche, not a node for every possible occupant of that niche
- Reusing animationtree structure for entities which have the same body but different expected animations for the same role (ex: a zombie and a human might share the same model and animationtree but via code the zombie requests a different idle animation or different death animation, instead of needing to create new nodes for them we can reuse the existing ones)
- (probably, haven't validated this yet) enable UGC animations to be played in animationtree without modifying tree
Describe the feature / enhancement and how it helps to overcome the problem or limitation
AnimationNodeAnimation could expose a new parameter animation to the AnimationTree that lets code change which animation it outputs.
Alternatively, if we don't want to change AnimationNodeAnimation, we could make a new node, something like AnimationNodeDynamicAnimation.
That way, if you have dozens of animations that fill a similar role, instead of needing to create separate animation nodes for each one, you can use a single node in the graph, which represents a niche, and you can use code to dynamically set the animation in this niche as required.
Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams
something along the lines of
// AnimationTree.cpp
StringName animation_param = PNAME("animation");
// helper
inline StringName _effective_animation() const {
Variant v = get_parameter(animation_param);
if (v.get_type() == Variant::STRING_NAME) {
const StringName n = v;
if (n != StringName()) {
return n;
}
}
return animation; // fallback to the shared property
}
AnimationNode::NodeTimeInfo AnimationNodeAnimation::get_node_time_info() const {
NodeTimeInfo nti;
const StringName anim_name = _effective_animation();
if (!process_state->tree->has_animation(anim_name)) {
return nti;
}
if (use_custom_timeline) {
nti.length = timeline_length;
nti.loop_mode = loop_mode;
} else {
Ref<Animation> anim = process_state->tree->get_animation(anim_name);
nti.length = (double)anim->get_length();
nti.loop_mode = anim->get_loop_mode();
}
nti.position = get_parameter(current_position);
return nti;
}
// etc, other places where animation is needed also use _effective_animation() helperIf this enhancement will not be used often, can it be worked around with a few lines of script?
If you don't use it, you can ignore it entirely
Is there a reason why this should be core and not an add-on in the asset library?
Important and useful functionality that makes animation trees more flexible and controllable via code.