godotengine / godot-proposals

Godot Improvement Proposals (GIPs)
MIT License
1.12k stars 69 forks source link

Allow multiple transitions with the same from and to nodes in Animation State Machine #4352

Open WindyDarian opened 2 years ago

WindyDarian commented 2 years ago

Describe the project you are working on

A 3D ARPG game

Describe the problem or limitation you are having in your project

I have a use case that is kind of hard to work around with the restriction of only one transition for each direction between two nodes. The simplified version is my character has attack and idle animation states, and I want to go back from attack to idle when either the animation is fully played, or the attack is interrupted for whatever reason. If I have only one transition with "At End", it seems I cant easily force interrupt the state to go to the next state.

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

I think allowing multiple transitions with the same from and to nodes will fix the problem. It be nice if the transitions can have different conditions, priorities and blend duration.

For my case, one of the transition will be "At End" for when attack animation fully play and return to idle. And another transition will have a condition with a script variable script, for when the attack animation needs to be interrupted manually.

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

I have my local code as a pull request at https://github.com/godotengine/godot/pull/59872 transitions

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

I feel this is a common enough case for action/animation heavy games. I find it hard to work around without another dummy "relay" node, and the dummy node needed to have animation hooked up as well.

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

I feel animation state machine is currently very limited and this can make it more flexible.

WindyDarian commented 2 years ago

closing per comments in https://github.com/godotengine/godot/pull/59872

MarkoSFG commented 6 months ago

Hey @WindyDarian - I'm running into the same requirements (and having to hack around by duplicating states) :) would love if this made it into engine.

WindyDarian commented 6 months ago

Hi! Please allow me to reopen the feature request. Per discussion on https://github.com/godotengine/godot/pull/59872

I think there are 3 different needs:

  1. with nodes A and B, allow transition from A to B under more than one conditions. (https://github.com/godotengine/godot/pull/61196 has this)
    1. with nodes A and B, when transitioning from A to B under different conditions, allow different fade times (this PR would have this)
    2. allow blending between more than two states during transition, or more than one fade happening at a time, for example, if going from A to B, before fade finishes go to C, should result in an animation blend of all A, B and C (https://github.com/godotengine/godot/pull/37001 )

There is still need to be able to set different fade length under different transition conditions. Allowing multiple transitions from the same nodes will be one way to have this. Though the PR is dated, and new code needs to be written if we want this.