0 votes

So this is the code for the portal that I did to to get the player from world1 to world2 to world_n.
extends Area2D

export(String, FILE, "*.tscn") var world_next

func onworldnextbodyentered(body):
if body.name=="Player":
get
tree().changescene(worldnext)

What happens in the debug window each time the player enters the collision box of the portal:
E 0:00:11.567 load: Resource file not found: res://.
<C++ Error> Condition "!file
check->fileexists(ppath)" is true. Returned: RES()
<C++ Source> core/io/resourceloader.cpp:282 @ _load()
world
next.gd:7 @ onworldnextbody_entered()

I just get this everytime I get in the portal. The thing is I tried to do this without the "export" command, a different script for each level, and it works.
Please help. Sorry if it's dumb but I just don't get it.

in Projects by (17 points)

1 Answer

+1 vote
Best answer

From your question I guess

gettree().changescene(worldnext)

should be :

get_tree().change_scene(world_next)

also make sure you actually select the .tscn file (The next world where you want the player to go) from the inspector window under Script Variables

by (403 points)
selected by

yes, i don't know why but the underlines don't appear here. they are in the original script.
I always choose the next world from the inspector window. I don't understand. Is there any other way to change between levels? Like a different command...?

As far as I know this should work just fine. I am not sure why the console says that the resource file was not found. Did you try restarting the engine ? Strange

So I spent 4-5 hours yesterday to figure out why it doesn't work, BUT I didn't think about restarting godot... I just opened it right now and it works. The strange ways of technology...
Thanks for the answer anyway.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.

Categories