Add state transition signals to AnimationNodeStateMachinePlayback#55423
Add state transition signals to AnimationNodeStateMachinePlayback#55423TheOrioli wants to merge 1 commit intogodotengine:masterfrom
Conversation
08d79d9 to
72ec76c
Compare
|
It needs to be reviewed and approved by contributors familiar with the animation workflows and their implementation. |
reduz
left a comment
There was a problem hiding this comment.
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 |
| // teleport to start | ||
| if (p_state_machine->states.has(start_request)) { | ||
| path.clear(); | ||
| if (current != StringName()){ |
There was a problem hiding this comment.
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.
"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
StartorTravel - 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
AnimationNodeStateMachinePlaybackwhich 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:
AnimationTreenode which manually checks for state changes every idle or physics frame, depending on settings. This is also very prone to user error.