godotengine / godot-proposals

Godot Improvement Proposals (GIPs)
MIT License
1.17k stars 98 forks source link

Improve AnimationNodeStateMachine usability #7277

Open Flynsarmy opened 1 year ago

Flynsarmy commented 1 year ago

Describe the project you are working on

Any involving an AnimationNodeStateMachine

Describe the problem or limitation you are having in your project

Working with AnimationNodeStateMachines currently feels very clunky with the way Select, Add, and Connect modes work. This adds to the time it takes to build more complex state machines and adds a small level of frustration whenever one is needed. There are also multiple missing features that would speed up the process of working with them though I might make separate proposals for those.

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

Remove the three input modes and handle everything with right and left click

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

Let's look at the current workflow of creating a state machine for a third person character.

The default mode is Select so we'll leave it on that.

  1. Right click - Add Animation - Find it in the massive list of animations (This really should be a scroll box with filter field at the top, but that's for a separate proposal)
  2. Do this two more times until we have Idle, Run, Jump animations
  3. You'll probably want to move them at this point. Be VERY precise with your mouse or you'll either hit the play button or the rename field:
  4. Click the Connect Nodes button and drag between your various nodes. In our case we want two way connections between all 3 nodes
  5. Click back to the Select mode
  6. Click each connection then in Inspector on the right set the switch and advance modes, conditions and expressions.
  7. Realize you forgot to make a connection from Start to Idle. Click back to Connect mode, make the connection then back to Select mode again. On anything more than extremely basic state machines you'll need to follow this step (really it's 3 steps) a lot.

This is an ultra simplified state machine and even it was a crazy number of clicks and mode changes: image The mode changes are really what makes this setup feel so clunky.

My proposal is a streamlining of this workflow.

  1. Delete the modes
  2. Move node renaming into Inspector and get rid of the click-to-rename mechanic
  3. Add a border around all nodes. This will be used for connections as described below.

Here's how I imagine the new AnimationNodeStateMachine functioning:

Let's now revisit the steps above but with my new setup (Including our mistake of not linking Start immediately):

  1. Right click - Add Animation - Idle
  2. Left click Drag from Idle's border to empty space and Add Animation - Jump. Again for Run.
  3. Left click drag between the node borders to make their two way connections
  4. Right click the connections and set the Switch and Advance modes.
  5. Left click any connections that need Advance Conditions and set them.
  6. Left click the Start border and drag to the Idle animation to complete our setup.

This feels significantly less clunky and faster than the current mode-based setup.

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

It would be used regularly.

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

Usability is important especially for something as complex and time consuming as a state machine. Getting it right often requires a tonne of tweaking and with the current setup that means potentially hundreds of mode changes and loading up of the Inspector eating time and sanity.

Flynsarmy commented 1 year ago

I've been thinking about this and an alternative to having borders on all nodes is to simply allow right clicking on the node and having a 'Make connection' option. This context menu would also allow other useful options such as 'Make Unique' for loaded state machine nodes or anything else we want to put in there.

vaner-org commented 1 month ago

It's a little alarming that shift-drag to make connections isn't more well known. Between left-click, right-click and shift-drag, all AnimationNodeStateMachine manipulations can be carried out from select mode.