- Edited
I am developing a mobile game in Godot 3.5.1 (because the converter to 4 is bad and I don't know how tilemaps now work).
I am developing a dungeon level in which I generate the 2D Terrain using OpenSimplexNoise. Now after that I loop through the empty tiles and spawn an enemy using this function:
func spawn_enemy(x : int,y : int) -> void:
var enemy := enemy_data.instance()
get_parent().call_deffered("add_child", enemy)
enemy.set_deffered("global_position", Vector2(x,y)
Now the problem is the enemy is always spawning at (0,0). I printed the x and y values which I'm passing to the function and they are random and not always (0,0).
Why is this happening ?
What other way can I try to set the position ?
I tried set_global_position() but it gave the same result.
I am frustrated.
Please help.