Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AnimationTree - Forced Animation Playtime Transition Option For StateMachine #2523

Open
yanorax opened this issue Mar 29, 2021 · 1 comment

Comments

@yanorax
Copy link

yanorax commented Mar 29, 2021

Describe the project you are working on

3D game that uses models with a bunch of animations that are controlled with an AnimationTree state machine.

Describe the problem or limitation you are having in your project

The AnimationTree StateMachine and its limited Transition options are giving me a lot of hassles and creating extra work in Blender when I should be able to control all behavior in the game engine. It is also forcing the number of frames that can be used for quick animations in a StateMachine.

For example, I want an animation to play for about half a second then cross-fade/blend over 0.4 seconds to the next animation. In a game it would be like swinging a sword and then returning to a looped idle animation.

To do this in Godot 3.2.x/3.3 I create an animation in Blender that is 24 frames that plays over 1 second.
In the AnimationTree StateMachine I create a BlendTree node that plays that animation at double speed (using TimeScale node) so it should take 0.5 seconds to complete.
The transition options are set to {Switch Mode - AtEnd} and Xfade time to 0.4 seconds.

What happens is the animation plays 60% of its frames:
original animation time - Xfade time => 1.0 - 0.4 = 0.6 = 60%
It takes 0.3 seconds to get to that point:
original animation time at double speed * 60% => (1.0 / 2.0) * 60% = 0.3 seconds
Then it starts the cross-fade/blend and transitions to the next animation over the next 0.4 seconds.

To play the entire animation instead of 60% of it, I would need to work out how to adjust frame count in the animation to get it to line up with the 0.4 seconds X-fade time. At 24fps played at double speed the entire animation would need to complete in 14 frames (24 x 60%) and the rest of the frames are pad. If the animation is played at 4x speed, it would be 38 frames out of 48 frames to complete the animation.

I just want to be able to create animations in Blender at any frame count and not have to worry about padding extra frames, etc. For complex animations that play quickly (half a second duration), I need many frames to create each animation and then play them at double or triple speed in the game engine.
I also don't want to have to create more AnimationTree StateMachine nodes to serve as an additional transition buffer between the nodes. Those buffer nodes would need their own animation as well.

Describe the feature / enhancement and how it helps to overcome the problem or limitation

I had a look at the other major game engines and they have some options that should be implemented in Godot in some form or another. Links to the manual pages:
https://docs.unrealengine.com/en-US/AnimatingObjects/SkeletalMeshAnimation/StateMachines/TransitionRules/index.html
https://docs.unity3d.com/Manual/class-Transition.html

The transition options need to be expanded to at least include the following:

  • Play Time / Exit Time: Define a normalized amount of time that the animation must play before the transition. This allows us to play the entire animation (Play Time = 1.0) and then any cross-fade time is added at the back if we want. This calculation must take into account any TimeScale nodes used.

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

The AnimationNodeStateMachineTransition class and Inspector GUI would need the PlayTime field added:

  • Switch Mode
  • {Enable/Disable} Play Time (check box)
  • var_play_time (float)

  • Auto Advance
  • Advanced Conditions
  • Xfade Time
  • Priority
  • Disabled

If this enhancement will not be used often, can it be worked around with a few lines of script?

Transition options are fixed and can not augmented by script.

Is there a reason why this should be core and not an add-on in the asset library?

AnimationTree is already a core Node and any modification should be apart of the core.

@fire
Copy link
Member

fire commented Feb 9, 2022

See also #2200. Wanting to make a tracking issue for the issues and proposals.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants