Add support to AnimationPlayer for relative changes to properties. #9005
Closed
SeanRamey
started this conversation in
General Discussions
Replies: 2 comments 1 reply
-
This sounds like the same as: |
Beta Was this translation helpful? Give feedback.
1 reply
-
Closing as per above, thank you nonetheless 🙂 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi, I've run into a situation where it would be invaluable to be able to animate the position of a Node2D by relative values instead of absolute values. I DO NOT mean like this issue talks about: godotengine/godot#4263
What I mean is I want to create an Animation on say a Node2D that does a simple movement, like move it up by so many units. So basically, the same as doing
position.y -= 4
. Then, have an overarching AnimationPlayer use this "move up" animation many times, but not have it keep resetting each time it's played, and instead actually move it by that 4 unit amount each time. So for example, ifposition.y
= 0 at the start, and I play the "move up" animation 5 times,position.y
will equal 20 at the end of the overarching AnimationPlayer's animation. This way I can very precisely choreograph things.This problem came about when I was trying to exactly recreate the title screen animation for the original Frogger arcade game, which has 7 frogs hop across the screen one after the other into their positions so they can be changed into each letter of the name of the game "FROGGER".
The problem is that they don't move smoothly, but in jumps of 4 pixels at a time, each time the frame is changed on their sprite animation, which is about 8 frames per second.
To animate their positions and still keep the look matching the original behaviour, I would need to create 224 key frames for their positions ( 4 movements per tile, 56 tiles to move distributed across 7 frogs) and another 224 key frames for their sprite frames, making up 448 key frames. So instead I had to just write a function that starts doing the "walk" and a function that stops the "walk", then just play with the timings to get them to land in the right spot. And every time I make changes, I have to sit through the entire animation in-game to see if I got it right, because you can't see function call's effects when playing an animation in the editor.
If I could use relative positions in an AnimationPlayer, then I could create an animation for the frog that would play a complete cycle of the "walk" animation ( 8 frames of sprite animation with 8 pixels moved each frame for two tiles of movement). Then reuse that "walk" in an overarching AnimationPlayer to precisely position the frogs with considerably less key frames (28 key frames, because each frog needs to "walk" to a position that is a multiple of 2 tiles away, decreasing by 2 tiles for each frog which is 56 tiles divided by 2 because each "walk" animation does 2 tiles)
It seems logical that an Animation has to have concrete data for each key frame that has to be known ahead of time, which would seem to make relative changes difficult because you don't know what the actual number will be on each key frame... but I believe you can know, you just need to know what the starting position is, how many times the position changes each animation and by how much. Then you can extrapolate that information to calculate the exact positions over the course of the overarching animation.
Another potential solution for this problem would be to allow autopopulating of key frames by say, drag selecting a track's time duration to add the key frames, then giving the rate per second to add the key frames and the relative offset for each key frame's data, then automatically adding all those keyframes at the specified rate with each one changing by the offset.
So say I want 10 seconds of keyframes that change
position.y
by adding 4 each key frame, and I want them at 8 keyframes per second, it could just do that automatically very easily.Beta Was this translation helpful? Give feedback.
All reactions