Get_tree() method soft failing with error. Why?

Godot Version

4.3.stable

Question

I have a sanity check in a method to verify if the scene tree exists and it works fine. The thing is, I get a debugger error. I’d like to understand why it’s relevant.

I call it thus:

	if get_tree() != null:
		get_tree().create_timer(0.15).connect("timeout", Callable(self, "_health_flash_timer"))

This generates the following Debugger error:
image

I know I can just ignore it. It’s not really an issue as the game works fine. But I’m wondering if maybe there is a better way that I’m not seeing right now.

Thanks.

Try if is_inside_tree() instead

Yeah, that does work, thanks.

Also, I checked that method’s doc and, ironically, it suggests to read on get_tree(). I hadn’t read the latter and it is stated that get_tree() will generate an error if null.

I’m just wondering why it is necessary to throw the error.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.