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: travelling directly to a state inside a SubStateMachine doesn't work, even though the transition is valid. #62576

Closed
Tracked by #73534
eh-jogos opened this issue Jun 30, 2022 · 4 comments · Fixed by #75759

Comments

@eh-jogos
Copy link

Godot version

4.0.alpha10

System information

Manjaro Linux, Nvidia proprietary drivers, Vulkan Clustered

Issue description

So this is the animation tree for my beat em up character
image

I added the hurt and knockout states today, and it made a whole mess of it, since you can go from any ground state to any hurt state and from almost any state to knockout_launch.

I was trying to see if I could organize or do this in a better way, as I still have more attacks and grab/throws to add, when I noticed we can now add transitions directly to another state inside an AnimationNodeStateMachine! Wonderfull! In fact I had not done jump as an AnimationNodeStateMachine because I needed to be able to go to the "falling" state at any time, but now that I know I can create transitions directly to it, I was able to reorganize my AnimationTree like this:

image
Much better!

But when I tried to code the transitions, it doesn't work.
If, for example, I do:

_playback.travel("attack_group/attack1")

I get:

E 0:00:00:0569   _travel: Condition "!p_state_machine->states.has(p_travel)" is true. Returning: false
  <C++ Source>   scene/animation/animation_node_state_machine.cpp:179 @ _travel()

(link to github source I got from right clickig error)

Even though this:

var state_machine = _animation_tree.tree_root["nodes/state_machine/node"] as AnimationNodeStateMachine
var value = state_machine.has_transition("idle", "attack_group/attack1")
_playback.travel("attack_group/attack1")
print("value: %s"%[value])

prints true:
image

So when I ask AnimationNodeStateMachine if the transition is valid through GDScript, I get a true, but apparently the AnimationNodeStateMachinePlayback can't find it.

If needed I can provide prints from the "child" state machines or from the transitions in the inspector, I was just trying to not spam the description with even more images.

Steps to reproduce

Use the MRP below, or:

  1. Create a Scene with at least two animations
  2. Create an AnimationTree with a AnimationNodeStateMachine as root
  3. Add one animation directly and another inside a new AnimationNodeStateMachine
  4. Connect the outside animation directly to the inside animation
  5. Try to travel to it.

Minimal reproduction project

broken_animation_tree.zip

The default scene has everything set up, just run it and use the arrow keys to try to play different animations
image

Only ui_right and ui_down will work, as they are transitions between the "idle" state and the "move_group" state, both which are on the same AnimationNodeStateMachine.
image

ui_up and ui_left which are transitions from "idle" directly to AnimationNodeAnimations inside the "move_group" AnimationNodeStateMachine, will not work, even though they'll print that the transition is valid (when you are coming from idle)
image

@guilhermefelipecgs
Copy link
Contributor

guilhermefelipecgs commented Jul 31, 2022

At the moment travel only works for states in the same state machine. I think I can change that. I'll take a look.

@eh-jogos
Copy link
Author

@Calinou Shouldn't this be tagged as 4.0? As connections to states inside another AnimationNodeStateMachine are not available on 3.x (at least up to 3.4), and this is only a bug if I can make this connections in the editor but not travel to them in runtime.

@Calinou Calinou added this to the 4.0 milestone Aug 14, 2022
@TokageItLab TokageItLab modified the milestones: 4.0, 4.x Jan 15, 2023
@eh-jogos
Copy link
Author

@TokageItLab just noticed this was moved to 4.x, wouldn't it be better to remove the UI that allows for connecting a state node directly to a child state node of another state machine? I mean, if I can't travel to it, why can I connect it?

Or is this a problem only when trying to use travel from code, but if you use conditions for auto-traveling it works?

@TokageItLab
Copy link
Member

cc @SaracenOne @guilhermefelipecgs

@TokageItLab TokageItLab changed the title AnimationTree: travelling directly to a state inside a child AnimationNodeStateMachine doesn't work, even though the transition is valid. AnimationTree: travelling directly to a state inside a SubStateMachine doesn't work, even though the transition is valid. Jan 19, 2023
@TokageItLab TokageItLab modified the milestones: 4.x, 4.1 Feb 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants