How do you create a sequential Tween effect in Godot 3.0?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By AbstractGameDev

I’ve been following the instructions of how to create a “jump”-like Tween transition in Godot 3.0 over here: https://forum.godotengine.org/14993/how-can-i-achieve-set_pos-as-a-parable-with-tween-node?show=14993#q14993

However, for some reason it doesn’t seem to work in Godot 3.0. Apparently, whenever I create multiple Tween transitions to form a Tween sequence, it only performs one of them. I’ve tried various combinations, it doesn’t seem to work as intended.

Does anyone have any suggestions of how to write a jump like animation with Tweens just like the one described in the link in Godot 3.0?

:bust_in_silhouette: Reply From: Diet Estus

If you must use Tweens, you could do something like this.

func parabolic_movement(target_node, start_x, end_x, start_y, end_y, duration):

    # tween x position linearly across duration
    tween1.interpolate_property(target_node, "global_position:x", start_x, end_x, duration, Tween.TRANS_LINEAR, Tween.TRANS_LINEAR)

    tween1.start()

    # tween y position in two parts, each across duration/2

    # first tween upwards and wait for the tween to finish
    tween2.interpolate_property(target_node, "global_position:y", start_y, end_y, duration/2, Tween.TRANS_SINE, Tween.EASE_OUT)    
    tween2.start()

    yield(tween2, "tween_completed")

    # then tween downwards
    tween2.interpolate_property(target_node, "global_position:y", end_y, start_y, duration/2, Tween.TRANS_SINE, Tween.EASE_IN)
    tween2.start()

But typically I would just code this kind of movement directly in _physics_process() using variables to represent velocity, acceleration, and gravity.

Hey, thanks for the answer. I implemented it and it works. You’re right about it being more logical to code a structure for a jump rather than using a Tween.

I experimented with the idea of drawing a line, via the _draw(): function, set its opacity to 0, converting it into a PoolVector2Array, then apply it to a Path2D / PathFollow, which the object would follow. But, I’m not certain how to handle that. It’s a bit more complex, and I’m still learning the optimal use of Godot. I’d honestly rather do that, but apparently I can’t make it work properly.

If you have any ideas for such a “limited”, restrained, one-time jump, I’m listening. It’s not for a player input by the way, it’s a for an player item.

AbstractGameDev | 2019-01-23 15:27