Not sure how to set position of a spawned entity

player scene
shoot.emit(global_position)

main level scene
const bullet_scene: PackedScene = preload(“res://bullet.tscn”)

func _on_player_shoot(pos: Vector2) → void:
var bullet = bullet_scene.instantiate()
$Bullets.add_child(bullet)
bullet.position = pos

Question

To me this should be spawning the bullets on the player but instead they spawn at the origin point

Try setting the position before you add_child

No still puts it at the origin point.

Try to print what you get in “pos” variable in_on_player_shoot function, just to check value.
Also may try this, instead of last line:

bullet.global_position = pos
1 Like

Your player scene emits the global position, but your handler places the bullets in the local position.

Use bullet.global_position = pos

1 Like

Maybe unrelated, but this solved my problem with a child spawner node, where its children would clamp to that spawners relative position instead of to the global viewport position. I didn’t know you had to differentiate for child nodes. But changing the clamping code from
position = position.clamp(Vector2(0, 0), screen_size)
to
global_position = global_position.clamp(Vector2(0, 0), screen_size)
solved the issue.