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

Add next/reset function to AnimationStateMachine #71264

Merged
merged 1 commit into from
Jan 19, 2023

Conversation

TokageItLab
Copy link
Member

@TokageItLab TokageItLab commented Jan 12, 2023

Closes godotengine/godot-proposals#2200
Closes godotengine/godot-proposals#5964

  • Fixed glitch in the first frame of the transition. This was caused by the same animation being blended twice.
  • Split start and travel requests. This allows for the generation of new paths in a single frame, as shown below:
if Input.is_action_just_pressed("ui_left"):
	asp.start("Start")
	asp.travel("End")
  • Implements next(), which immediately transitions paths if the next path exist. This method allows transitions without changing the AnimationStateMachineTransition condition.
sti1.mp4
  • Implement the reset option, which was added to NodeTransition under the name from_start (see also Add sync to NodeTransition and BlendSpace1D/2D and refactor sync in AnimationTree #62623), but since it is confusing with the StateMachine Start node, it is unified reset. I don't have any idea how this would be useful for non-looping animations, but for looping animations, it is useful if you want to resume the animation in the middle of a loop. Also it is necessary to avoid losing synchronization in the sync option.
sti2.mp4

state_machine_improvement_demo.zip

@SaracenOne
Copy link
Member

SaracenOne commented Jan 12, 2023

This looks good, though as we discussed in messages, I'm considering feeling that the name should probably be chosen as opposed to the broad 'interrupt' function since it could have a variety of different meanings. I also still need to properly evaluate requirements for the 'reset' flag, but I'll do a full review soon!

@TokageItLab
Copy link
Member Author

TokageItLab commented Jan 15, 2023

If reset is false, it would be correct to move to the further next state with processing no frame if the next state has already ended, but the current end process is a bit odd to begin with (I guess that it is probably related to #68986), so I will look at this in the next PR.

@reduz
Copy link
Member

reduz commented Jan 19, 2023

Looks good to me, but make sure to agree on the naming

@TokageItLab TokageItLab changed the title Add interrupt/reset function to AnimationStateMachine Add next/reset function to AnimationStateMachine Jan 19, 2023
@akien-mga akien-mga merged commit a202f51 into godotengine:master Jan 19, 2023
@akien-mga
Copy link
Member

Thanks!

@TokageItLab TokageItLab deleted the improve-statemachine branch February 14, 2024 05:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants