|
|
|
|
Attention |
Topic was automatically imported from the old Question2Answer platform. |
|
Asked By |
biroiulian |
So this is the code for the portal that I did to to get the player from world_1 to world_2 to world_n.
extends Area2D
export(String, FILE, “*.tscn”) var world_next
func _on_world_next_body_entered(body):
if body.name==“Player”:
get_tree().change_scene(world_next)
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->file_exists(p_path)” is true. Returned: RES()
<C++ Source> core/io/resource_loader.cpp:282 @ _load()
world_next.gd:7 @ _on_world_next_body_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.
|
|
|
|
Reply From: |
Scavex |
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
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…?
biroiulian | 2020-07-03 17:41
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
Scavex | 2020-07-03 18:01
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.
biroiulian | 2020-07-03 19:30