Position doesn't update on object after loading new scene to the right of current scene

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By talador

I have a one shot particle effect that doesn’t show up when I load the second scene to the right of the current scene. If I play the scene by itself the particle effect works when I run into an object. The Area2D “body_entered” still works, but it think’s it’s position is one screen size to the left so I have to do something like this:

#coin.gd

const SCREEN_X = 480        

func _ready():
	glo = get_node("/root/global")	
	particle_packed = preload("res://env//script_obj//coin_particle.tscn")
	get_node("Area2D").connect("body_entered", self, "trigger_enter")
	
func trigger_enter(body):
	if body.get_name() == 'player':
		var particle = particle_packed.instance()
		particle.position = position
		particle.position.x += SCREEN_X * (glo.current_level -1) #why this
		get_tree().root.add_child(particle)
		glo.coin_found()
		queue_free()

What is glo and particle_packed? I don’t see them defined anywhere.
Also I don’t fully understand the problem or how it happens.
Is your coin_particle.tscn scene centered at the origin?
Also are you sure the position you set it to is actually correct, relative to the parent of your nodes? (verify what’s local and global)

Zylann | 2018-08-10 12:52