Spawn point not working

Godot Version

4.2.2

Question

Can someone help me figure out why my spawn point is not working?

I have two spawn points for the enemy. Each a Marker2D and in the group spawn_location. Both markers are children of the world scene. The create enemy instance code is in the world script.

This is where the ghost spawns relative to the spawn location

This is what I am using to spawn the enemy.

var enemy_instance = enemy.instantiate()
add_child(enemy_instance)		
var nodes = get_tree().get_nodes_in_group("spawn_location")
var node = nodes[randi() % nodes.size()]
enemy_instance.position = node.position

Thanks

Figured it out, the scenes being loaded were not positioned on the 0,0 spot, so they were offset a distance away from 0

Try using global_position instead of position.
Position is relative to the parent, so if they have different parents the values are going to be different.

1 Like

ah, good to know. Thanks