Instantiated scene not spawning where intended

Godot Version



Hey all, I am trying to load in a bullet image but am unsure how Godot decides the spawn location of a scene in relation to the image and Nodes tied to it. It keeps dropping the image far below and to the right of where I would expect it to be loading into the scene.

My Node tree looks like this:

\-- RPG (Area2D)
\---- CollisionShape2D
\---- Rpg (Sprite2D)
\------ ShootingPoint (Marker2D)

I have “ShootingPoint” marked as a Unique Named Node and my code to instantiate the Rocket looks like this

func shoot():
	const ROCKET = preload("res://Scenes/Ammo_Scenes/rocket.tscn")
	var newRocket = ROCKET.instantiate()
	newRocket.global_position = %ShootingPoint.global_position
	newRocket.global_rotation = %ShootingPoint.global_rotation


That red cross on the front is the “ShootingPoint” but when the Rocket image loads in it loads in like this below it. This forum only lets me load in 1 picture so I can’t show what it actually looks like but hopefully I can add more details in the comments.

I would want the rocket to load in where directly on top of the red cross indicated by the “ShootingPoint”. And if that is not possible I just want to know how Godot makes the decision to spawn where it does so I can accommodate for it in the future.

Here are the additional images that are important to understanding the issue.

This is how the rocket spawns current state:


The Rocket’s scene file on it’s own looks like this:


just reset the position of the Rocket to 0,0

1 Like

Do you mean in its own scene or when I load it into the scene with the weapon?

Try setting the new_rocket global position after adding it as child.

1 Like

Nailed it, thank you!

Still not 100% on why it would have decided on the location it was choosing to spawn it at originally, but changing the order here did fix the issue.

I’ve also not been able to find the behavior consistent. Sometimes setting it before adding as child works and some times it only works after adding it as child.

1 Like