Open mhoff12358 opened 2 years ago
I'll just leave this one here in case it may help anyone to workaround while the feature is not yet there: https://godotengine.org/qa/42831/root-motion-in-2d. At least in my simple case it worked out well enough
The feature is very desirable! š
@AccumPlus Please don't bump issues without contributing significant new information. Use the :+1: reaction button on the first post instead.
on #1191 someone suggested the following:
You can use a parent-child node structure to effectively get relative transforms
https://github.com/godotengine/godot-proposals/issues/1191#issuecomment-658106154
and you can read my expereince/response in here
https://github.com/godotengine/godot-proposals/issues/1191#issuecomment-2294808679
i added a detailed description in there, on why, that may not be such a good idea of a solution, but in case someone wants to go through that whole process they may go ahead, and read the details of potential problems that you may face. Granted as i mentioned in my comment in #1191 i believe its possible, but it'll probably be around 1500 lines of code to go through and fix all of these edge cases, and depending on your game, you may face even more, which is not feasible, which leads me to make this comment in here.
as i said in the other ticket about relative frames #1191 i think the core, and true focus, should be root motion in 2D because of the following reasons:
With that said, i am a bit new to the godot source code world so i could be saying a lot of non sense that does not fit to godot world and sorry if that is the case.
but i would love to hear what more expereinced developers think about whether it would be fine to just hard code a solution for 2D similar to what was done for 3D and if not, what prevents such thing from happening?
@MotasemZakarneh I can see there are methods like get_root_motion_position()
in AnimationMixer
(and, consequently, AnimationPlayer
& AnimationTree
). You can also specify root_motion_track
, so maybe the feature is there already, only the related issues not closed?
now, i could be just stupid, and have missed something essential, but in godot 4.3
i simply can not seem to select any root motion track š in this setup of a scene obviously, i tried removing the node3d parent, and keeping a node 2d one, or whatever, but neither really works, i could not specify/select anything in the inspector. (even dragging and dropping did not work).
Describe the project you are working on
A 2D game where the player fights enemies whose attacks (and their properties like hit boxes) are defined by animations
Describe the problem or limitation you are having in your project
The lack of root motion for 2d transforms means that playing a new animation resets the Node2D's position rather than letting it aggregate.
Describe the feature / enhancement and how it helps to overcome the problem or limitation
In addition to being able to select a 3D Position track as the source of root motion, also allow value tracks that are Node2D position values to be selected. Then any animation changes to that track won't actually be applied to the Node2D directly, and will instead be exposed through the root_motion property of the AnimationTree. Users can then apply this offset through their own scripting, either directly or through a CharacterBody2D's move_and_slide method.
Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams
The basic functionality for this already exists for 3d root motion. This will replicate that code but for 2D transforms instead. https://github.com/godotengine/godot/pull/65183 shows this working for 2D positions.
One issue is that in 3D it's more obvious how to have the user select the position AND rotation AND scale. For 2D the best idea I have is to have them select the position track and then also implicitly look for the nearby rotation and scale tracks.
If this enhancement will not be used often, can it be worked around with a few lines of script?
No, this cannot be easily worked around with scripting. It would require a lot of wrapping around animation playback and might not work in all edge cases.
Is there a reason why this should be core and not an add-on in the asset library?
It is a feature added to the existing AnimationTree node, changing existing method behavior. So adding it through a plugin would require recreating core functionality.