godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
89.42k stars 20.24k forks source link

AnimationTree animation flickering #34440

Open grevius5 opened 4 years ago

grevius5 commented 4 years ago

Godot version: 3.1.2 >

OS/device including version: Linux

Issue description: All the animations that execute the AnimationTree are flickering IF you leave one animation in the AnimationPlayer with the AutoPlay flag. You have no error and this mistake is hard to identify and resolve. It's better to deactivate that flag automatically when the AnimationTree is activated maybe

igorcafe commented 3 years ago

Thanks for saving my day :D It should have a warning or something like you described...

Calinou commented 3 years ago

@grevius5 @igoracmelo Please upload a minimal reproduction project to make this easier to troubleshoot.

hsandt commented 1 year ago

Here is a minimal repro on Godot 3.5.1:

v3.5.1 - Infinite animation flicker on Auto Advance.zip

image

image

Just open the project, select the AnimationTree and preview the changes to see transition flicker.

Here is a minimal repro on Godot 4 rc2:

v4.0.rc2 - Infinite animation flicker on Auto Advance.zip

image

image

Do the same to see the flicker.

The concept is the same in both, you can see green arrows meaning transitions are set to Auto mode, and since they have no condition, they keep switching to the next state indefinitely.

In Godot 4, auto-advance bool has been replaced with Advance > Mode enum, but the concept is the same. When set to Auto with no expression, which is the default, the transition immediately applies. If a circular transition chain exists, this causes infinite flickering.

It is however worse in Godot 4 because Auto is the default mode (although you can click on the revert button to switch back to Enabled, which suggests that Enabled should be the correct default value).

In Godot 3, as we said we can add some warning, esp. if a circular path is detected, switch mode is Immediate and conditions are empty.

In Godot 4, I see several improvements possible: a. Make Enabled the default mode for new transitions, so animation only changes on call to travel() b. On new transition creation, fill the Auto transition condition with a parameter yet to be set like transition_parameter, or set the transition expression with something falsey (like... false) c. When Auto transition condition/expression is empty, consider it never fulfilled (akin to Unity Animator Controller which shows a warning when there is no transition condition as it will never happen). Invite user to set condition to true if they really want that. d. As suggested for Godot 3, show a warning if a transition combines Switch Mode Immediate (or Sync) and Advance Mode Auto with no condition (or condition hardcoded to "true"). Invite user to set Switch Mode to AtEnd for true auto-chained transition if they want (useful for natural transition animations like IdleToCrouch -> Crouch)

Btw the doc about transition condition and expression is incomplete, and naming ambiguous. I though that Condition that the expression, but in fact it's more like a bool parameter name you'd have for a transition condition as in Unity's animator controller; while expression is an arbitrary expression, but I don't know how to access external vars from this context. But that will be for another ticket.

hsandt commented 1 year ago

OK, I see why in Godot 4, Auto is the default mode: it's for the Start to first animation transition to work immediately.

Then we could make Enabled the default, except when transitioning from Start (for the first time), in which case it'd be Auto.