Hi
i wrote a code that creates the player object on each level the player enters and I want it to also support editor placed player objects. that’s where I have problem, the script created player works properly when i change it’s position with the position variable but for some reason the existing player object goes to wrong coordinates when trying to set it’s position
Here’s the code that handles both player creation and detecting existing player:
func _ready():
var currentPlayer = get_node("Pelaaja/Palomies") // Try to find existing player
print("New player! " + (str(currentPlayer) ) + " . " + get_tree().current_scene.name + " . " + (str(get_parent())))
// If no player create it
if(currentPlayer == null):
var scene = preload("res://palomies.tscn")
var instance = scene.instantiate()
add_child(instance)
print("instance " + (str(instance) ) + " " + (str(get_node("Pelaaja/Palomies"))))
currentPlayer = get_node("Pelaaja/Palomies")
so why does those two player objects behave so differently?
thanks!
(Sorry I forgot the Godot version but should be pretty much latest)