When changing scenes, they are overlapping one another what could be the reason?

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

For some reason my second scene overlaps my first scene during scene transition and all collisions remain from first scene. Im a beginner please help

tool

extends Area2D

export(String, FILE) var next_scene_path = “”
export(Vector2) var player_spawn_location = Vector2.ZERO

func _get_configuration_warning() → String:
if next_scene_path == “”:
return “next_scene path must be set for portal to work”
else:
return “”

func _on_Portal_body_entered(body):
Global.player_initial_map_position = player_spawn_location
if get_tree().change_scene(next_scene_path) == OK:
queue_free()
else:
print(“err”)

:bust_in_silhouette: Reply From: MrEliptik
get_tree().change_scene()

Already removed the current scene, so you don’t need to call queue_free(). I’m not 100% sure this is the problem, but you should start with that.

Hey thanks,
I tried that but it didn’t work.
But using
get.parent().queuefree()
seemed to work

bullet | 2021-03-20 17:58

:bust_in_silhouette: Reply From: bullet

Found the solution if anyone else is a noob like me.
get_parent().queue_free()
works