0 votes

Hey, I'm new and I was doing several tutorials when i found the error in the title

I wrote a code where if a ball gets out of the screen, several things happen:

func _on_VisibilityNotifier2D_screen_exited():
var replay_scn = load("res://title/replay.tscn")
get_tree().paused = true

there is a part of the code when I press a button

func _input(event):
if event.is_action_pressed("iniciar") and not iniciado :
elif event.is_action_pressed("iniciar") and iniciado==true :
    get_tree().change_scene("res://World.tscn") ###ERROR HAPPENS HERE####

When I change the scene in this point, the following error appears

canprocess: "!isinside_tree()" is true. Returned: false

and after that I am not able to unpause the game and it freezes

I am also noob in terms of formullating questions, so if you need more information, i'll give you.

Ty guys and sorry for bad indentation in code copying

Godot version 3.2.3.stable.official
in Engine by (12 points)

1 Answer

0 votes

I don't have the exact answer to your problem, but I stumbled across on that error myself.
It usually happens when you instance something, apply properties to it before adding it to the scene tree(sorry if I made it more confusing, English isn't really my first language). To illustrate:

var camera_pck = preload("res://custom_camera.tscn")
var camera = camera_pck.instance

camera.global_position.x = 900

These snippet of code would generate this error:

getglobaltransform: Condition "!isinsidetree()" is true. Returned: gettransform()

In order to fix it I just move

camera.global_position.x = 900

after add_child(camera), likeso:

camera.global_position.x = 900
by (340 points)
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 Frequently asked questions and 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 [email protected] with your username.