-
-
Notifications
You must be signed in to change notification settings - Fork 21.1k
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 markers to Animation #91765
Add markers to Animation #91765
Conversation
053d6dd
to
8926c10
Compare
Exists the possibility to can loop a specific section only for a finite number of cycles? |
It would be easily implementable by GDScript when/if #89525 gets merged. |
I'm interested in markers for animation, will try to review for Godot Engine 4.4. |
8926c10
to
2f9db78
Compare
I had been discussing and supervising on discord with @chocola-mint before this was sent, so this PR should be quite clean in terms of architectural design. I will test the behavior in more detail later, but I send feedback at this stage: AnimationPlayer needs an api to set/unset section during playback. It corresponds to the enabling of the use custom timeline option in the AnimationNode in AnimationTree. The API allows for A-B repeats in a BTW sorry, since the use custom timeline option in AnimationNode is newly implemented and I found a problem with the offset being inverted. I have sent an urgent PR about this as #91822 and would appreciate it if you could take a look at it and proceed with the implementation. The warning about duplicate names when adding markers is not needed. It should be consistent with the GUI when adding other animation resources. New icons for markers need to be added. How about the following? |
2f9db78
to
449afd1
Compare
godot_anim_markers_v4_8.mp4 |
56a12f1
to
08afead
Compare
I'll give this a look, I have some project setups which should hopefully allow me to test this. |
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.
Still investigating, but at first look, it appears this PR might have caused regressions with root motion calculation and will need to be fixed before merging.
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.
Another small issue I noticed is if you have a marker selected and switch from the timeline display in seconds to FPS, the time in the marker changes to reflect the frame number, but if you go back to displaying the timeline in seconds, the time is still displayed as a frame. Small UI issue, but something I noticed in testing.
8f5e840
to
a1cbf60
Compare
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 double checked and there are some issues with RootMotion, but I don't think they are directly related to this PR.
One problem of the RootMotion I have known is the possibility of calculation discrepancies in the first and last frame, but this is related to #90345, and I don't think this PR affects it.
Also, if it has a few keys, it may be possible for the user to be unintentionally affected by the loop_wrap option when the interval is specified, but this is not a blocker as it is a documentation issue.
I think it is mergeable for now.
I want to look into this a bit deeper myself before I feel fully comfortable giving the go ahead to merge. I agree that even if that even if the root motion problem has issues elsewhere, something here has exacerbated the problem and I want to be sure. The thing I'm discovering now that may help narrow this down is that the root motion breaking doesn't just happen in any context, but its specifically breaking when used in the context of |
This PR does not change much about the AnimationTree; there are some known issues with RootMotion blending, so #95688 may give you a hint. |
Hmm...I've been doing testing myself, but @TokageItLab can you confirm if this is the same issue you're describing: it seems that what is happening on my end is that code that calculates the I think what's happening in the context of the animation tree, we're |
Since I know we want to get this in and I feel like its a good implementation of this feature which will unlock a lot of advanced features we can do with animation playback in the future, I won't block this any further if we would prefer to fully debug root motion issues seperately. I just wanted to be sure we're talking about the same bug. |
I could be completely wrong, but is it possible that inserting something like:
On line 255 of |
This on line 246 of
|
@SaracenOne Ah indeed, those values are newly implemented in the PlaybackInfo, but the setting value process on the AnimationTree side seems to be lacking. So it would make sense to set the values, but in my opinion they need to be set earlier, as they are valid outside of the |
@TokageItLab Hmm...do we perhaps want to assign the playback_info's end value in the AnimationNode's base |
4e15b81
to
14cf17a
Compare
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 would recommend changing
pi.start = start_offset;
pi.end = start_offset + cur_len;
to
pi.start = 0.0;
pi.end = cur_len;
since the former approach still has issues with root motion when used with BlendTree animations using custom timelines.
14cf17a
to
ed13a84
Compare
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.
LGTM 👍
Thanks! |
Would it be possible to make it so when an animation reaches a marker, a signal is made? This would greatly simplify timer-based features in a sequence. func _ready():
animation.play()
func _on_animation_marker_passed(animation_name, marker_name):
if animation_name = my_animation && marker_name = my_first_marker:
spawn(my_object_1)
if marker_name = my_second_marker:
spawn(my_object_2) Thank you for your work btw :D (edit: thanks to @TokageItLab I have been introduced to method tracks. LOL. I noticed that this comment got some likes(? reactions?) and I will make a simple video on how to quickly do what I exampled in the code block above. If anyone has interpreted this comment for a different use with signals, please make a new comment and explain yourself. Thank you!) |
@ComfyZenny Wouldn't it be enough to just call the To summarize, it is theoretically possible with only AnimationPlayer, but it is a duplication of functionality and not possible for consistency with the AnimationTree. So it should be superseded by an add-on or any script that converts the markers to Method tracks. |
Bugsquad edited:
This PR introduces a marker system for Animations. Markers are keys that are inserted alongside the timeline, and can be used to play specific parts of animations. A pair of markers is called a section.
For the Animation resource class, there are now new methods to query marker information with.
For AnimationPlayer, there is now a new
play_section
method that can be used to specify a pair of markers that denote a playback section.play
method is equivalent to passing empty strings as start and end markers toplay_section
.in which case the AnimationMixer effectively does nothing while playing the out-of-range part of the section. (FEEDBACK WELCOME: Is this behavior desirable?)The AnimationMixer will clamp the end of the section so it does not exceed the Animation's length.play_section
uses the original Animation's loop mode.godot_anim_markers_v4_7.mp4
For AnimationTree, specifically AnimationNodeAnimation, Custom Timelines can now be configured using the
Set Custom Timeline from Marker
button.godot_anim_markers_v4_5.mp4