Setting Position Of Sprite Doesnt Work

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

So i have this basic concept and so far i have a producer and a product. Im trying to make the producer produce the product but when it generates it’s meant to be on top of the producer but for some reason it puts it somewhere else

extends Sprite

func Produce():
    var sprite = load("res://Product.tscn")
    var s = sprite.instance()
    s.position = position

func _ready():
:bust_in_silhouette: Reply From: kidscancode

A node’s position is relative to its parent.

s.position = position is making the sprite’s local position equal to the parent’s. So, for example, if the parent is at (100, 100), you are setting your sprite to be (100, 100) away from the parent.

If you want the Sprite to be at the parent’s position, use s.position = Vector2(0, 0), and there will be no offset.