Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | buddyhoodie |
Hello guys Im an absolute beginner making his first game in Godot. Im making a platformer akin to the style of Super Mario Bros, with an object at the end of the level to take you to the next level.
I had this script found online and it worked for between world.tscn and world2.tscn but now that i added World3.tscn it wont work, instead of taking me there when i complete world 2 it takes me back to world 1. Here is the current code (job is the level changing object):
#Job.gd
extends Area2D
export(String, FILE, “*.tscn”) var next_world
func _physics_process(delta):
var bodies = get_overlapping_bodies()
for body in bodies:
if body.name == “Player”:
get_tree().change_scene(next_world)
immense thanks to anyone who could help me with this!!
Are you trying to persist nodes through different scenes?
Instead of using change_scene()
, you should probably go with a root node design pattern, where all scenes are children of a regular Node
, rather than a Viewport
. This way, scenes can be managed easier. Node persistence is easier this way as well.
Kyle Guarco | 2019-04-21 03:25
How could I do that? I’m quite the noobie but I’d appreciate if you could show me how I could solve my problem with the alternative you proposed, I have no idea how to do it
buddyhoodie | 2019-04-21 04:18