#how to i make the transition between jump animations smooth?

8 messages · Page 1 of 1 (latest)

wary python
#

I made a jump animation and i want to add it to my game, but the problem is that when i test it out, the transition between animations isnt smooth, even if i use the lerp function. anyone know how to solve?gdtired

jagged citrus
#

If understand your code correctly, that LERP_VAL value is a constant and if it is, you're using the lerp() function the wrong way. The documentation in the editor about the function might not be entirely clear, so I'll describe this function in detail and maybe give you some sources.

Basically, imagine a track with value A and value B at each end. As you go down the track, the value slowly morphs into the other value and how much it has morphed depends on how far down the track you went. You want to see what is half-way the track, so you go to 0.5 (or 50%) and check the value. That's what lerp does. Here's a primer for interpolation, also has some useful GIFs.
https://docs.godotengine.org/en/stable/tutorials/math/interpolation.html

If you want to use it for animation, you might want to rethink the approach of when you use lerp() and what value you'll use as weight. Alternatively, you can use Tweens, which should fit better with your use case of smooth transitions between several
https://docs.godotengine.org/en/stable/classes/class_tween.html

If you just want a transition between two animations and you don't want to do any mixing between them (just transitions), then check out AnimationTree's StateMachine node.
https://docs.godotengine.org/en/stable/tutorials/animation/animation_tree.html#statemachine

wary python
jagged citrus
# wary python Can lerps be used on variables and parameters?

lerp() function returns a value, so you can use its results as a new value for a variable. The most classic example of eased out camera movement code is to have current camera position and target camera position and lerp between the two in a _process function using delta as the weight. With each frame, the current position draws closer and closer to the target, but each move becomes slower as the difference in distance becomes smaller.

current_pos = lerp(current_pos, target_pos, delta)

Tweens should be able to morph variables too, it's their job. Godot says tween_property is for "properties", but for me it's ambiguous if variables also count. This is one thing you should give a try.

wary python
#

hhmm

wary python
#

@jagged citrus OMG THANKIES!

#

that helped alot!

jagged citrus
#

Glad I could help! Good luck in your endeavours!