Tweening a projectile to an enemy's position doesn't work properly

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

So, in my game, I have a player with an attack in which it uses a tween node to tween a projectile to a fixed position in the air, and then after that it will use tween to shoot the projectile at an enemy’s position. It will reach said fixed position fine, but when it’s supposed to tween to the enemy’s position, it won’t reach the enemy. It also keeps going down until it’s off the screen, which I presume is why it doesn’t reach the correct x position when it’s on screen, but since the enemy is obviously high enough to be on screen, it’s going lower than the enemy’s actual y position. Does anyone know why it goes lower than the enemy’s y position? For reference, here’s the code:

var tween: Tween = player.get_node("Tween")
tween.interpolate_property(beam_node, "position", Vector2(50, 0), Vector2(200, -250), 1)
yield(tween, "tween_completed")
yield(get_tree().create_timer(1), "timeout")
tween.interpolate_property(beam_node, "position", null, enemy.get_position(), 2)
:bust_in_silhouette: Reply From: Coweh

Okay, so, looking into it, I think it was just an issue with position being perceived differently as a child of the player node because children of the player node perceive the player’s position as 0, 0, or something like that, I just set the tween to tween to the enemy’s x position and a y position of 0.