how can I set a start position for a sprite in godot?

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

I have a script where I load a scene of my character, but when playing with its properties I have an error, just in the final line and this is the error “Invalid set index ‘position’ (on base: ‘PackedScene’) with value of type ‘Vector2’”. I hope you can help me:)

var enginner = load(“res://scenes/enginner.tscn”)
var pos = Vector2(0,5)

func _ready():

engineer.positon = pos

:bust_in_silhouette: Reply From: kidscancode

enginner is your PackedScene that you loaded on the first line. You can’t set its position because it’s not a node. When you call instance() on it you create a node, which is what you’re adding using add_child().

However, if you want to set that new instance’s position, you’ll need a reference to it:

func _ready():
    var new_sprite = enginner.instance()
    new_sprite.positon = pos