Tween pos in one axis

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By websterek
:warning: Old Version Published before Godot 3 was released.

Hi
I have bunch of Walls moving down with correct speed position etc. and I cant’s change it. Few of this walls needs to move also in side ways with randomly generated values. The best option for me in this situation will be Tween.

How can I use Tween only for one Axis?
I have found some info in internet about it but it’s seems to now working: Tween function for single axis position/translation · Issue #8257 · godotengine/godot · GitHub

tween.interpolate_property(get_node("Node2D_to_move"), "transform/posX", 0, 100, 1, Tween.TRANS_LINEAR, Tween.EASE_IN_OUT)

My walls are moving down using WallPos.y += 512*delta

Of course i have tween.start() and with normal values (for both axis) it’s working correctly.

Best!

Tween a variable and use it to update the position as mentioned here How can I achieve set_pos as a parable with tween node? - Archive - Godot Forum

eons | 2017-05-21 19:17

:bust_in_silhouette: Reply From: vinod

You need to put a Vector2 in place of the start and target values like this.

var n = get_node("node2d_to_move")
tween.interpolate_property(n, "transform/pos", n.get_pos(), n.get_pos() + Vector2(0,100), 1, Tween.TRANS_LINEAR, Tween.EASE_IN_OUT)