How to lock the position of an instanced node to its parent?

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

I have an Effect node consisting of Node2d > Sprite > AnimationPlayer. This node kills itself once its animation ends.

When my Player node takes damage, I instance this Effect node, set its position to the position of the Player node, and add it as a child of the Player node.

I also have a knockback on my Player node, so that when taking damage, it moves in the appropriate direction.

The problem is that once my effect animation spawns, its position does not get updated with the player, so the player slides out from behind it during its knockback.

Ideally, I want it to move with my player. I thought it was enough just to add it as a child of the player node, but apparently not.

So, my question: How can I link the position of this effect node to that of my player?

I do NOT want to write a script in the effect node (for example, using_process()) which looks for the player and manually follows its position. I am also using this effect elsewhere, and thus don’t want ad hoc code like this just for the player.

:bust_in_silhouette: Reply From: Diet Estus

Solved this myself. The question was based on a silly oversight.

Actually, it is enough just to add the node as a child of the parent and set

position = Vector2(0,0)

Position is local to the parent node.