-
-
Notifications
You must be signed in to change notification settings - Fork 21.5k
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
Add state transition signals to AnimationNodeStateMachinePlayback #55423
base: master
Are you sure you want to change the base?
Add state transition signals to AnimationNodeStateMachinePlayback #55423
Conversation
08d79d9
to
72ec76c
Compare
It needs to be reviewed and approved by contributors familiar with the animation workflows and their implementation. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! Please address the comments and should be ready to merge.
This doesn't seem to initially emit any signals when using Should it not emit signals in this case also? Something-something like: + // check if we have specifically jumped/teleported into a new state
+ if (current != previous) {
+ if (previous) {
+ emit_signal(StaticCString::create("state_exit"), previous);
+ emit_signal(StaticCString::create("state_changed"), previous, current);
+ }
+ emit_signal(StaticCString::create("state_enter"), current);
+ } |
72ec76c
to
99bd057
Compare
99bd057
to
da2b578
Compare
@reduz Thank you for the review, I have applied the requested changes to I've also added additional The new updated example project that allows teleporting/traveling to a specific state animation_state_machine_test.zip |
@@ -331,6 +338,11 @@ double AnimationNodeStateMachinePlayback::process(AnimationNodeStateMachine *p_s | |||
// teleport to start | |||
if (p_state_machine->states.has(start_request)) { | |||
path.clear(); | |||
if (current != StringName()){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am wondering if we should have
state_enter, state_changed, state_exit be emitted exclusively and without overlap from one to the other, so the order would be
- state_enter
- state_changed
- state_exit
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"exclusively and without overlap" meaning:
- state_enter is only emitted when entering into the machine for the first time, on the first state entered
- state_changed is emitted any time a state transitions into another valid state, automatically or using
Start
orTravel
- state_exit is only emitted when a machine stops
or something else?
Any updates on this? I think still waiting on clarification from @reduz |
poke. I too would like this feature |
tbh, this is such an ancient PR, it would probably be best to rebuild it from the ground up since a bunch of new animation changes have been made in the mean time. |
Adds signals to the
AnimationNodeStateMachinePlayback
which allow user-level scripts to react to transitions between the various states.What this means in practice is that it allows users to know when an animation/blend/sub-machine has stopped or started playing inside an
AnimationNodeStateMachine
. This can be used to solve problems presented in godotengine/godot-proposals#1462, #28311 and #41771Example project using this PR
This fix can also be easily backported to
3.x
, there seem to be no conflicts.The current ways to do the same thing on a user level are:
AnimationTree
node which manually checks for state changes every idle or physics frame, depending on settings. This is also very prone to user error.