I have a scene called TouchScreenButton that is expanding on some existing TouchScreenButton behaviour.

I was using the is_visible_in_tree in this scene to check if the menu is visible, and if not then to ignore all actions. I was getting the error constant error: _input: Condition "!is_visible_in_tree()" is true. every time I moved my mouse. The project stayed like that for weeks because I didn't mind the issue. There were thousands of instances of this error in the output screen so I decided to fix it. Now I don't use is_visible_in_tree() anymore, but a custom property enabled that I created and it's working fine, BUT - the error is still reported, even though when I search the whole project for is_visible_in_tree() I don't see any instances.

It's like an old version of the game is running, but then again, It's not, because I had other bugs in the same script and I fixed them. It's just that this error is persistent. How do I get rid of it?

Does the Godot debugger point to a place in the source code where this happens? Maybe we can look at the source code and work backwards to find what is causing it.

@TwistedTwigleg said: Does the Godot debugger point to a place in the source code where this happens? Maybe we can look at the source code and work backwards to find what is causing it.

This is the error:

I appended the full code for my TouchScreenButton scene.

This behavior bamboozles me.

The place in C++ source the code is referencing is here: Line 201. It looks like the TouchScreenButton is not visible, or rather the function is_visible_in_tree believes it is not visible.

Looking at the code, I do not see anything that would be causing the issue. The only thing I can think of that may help is adding something like self.visible = true to _ready, but I doubt it will fix the issue because if the node is visible in the SceneTree than setting it to visible in _ready shouldn't do anything.

Unfortunately, the self.visible = true isn't working.

Might that be because of my main scene layout?

The UI is a CanvasLayer inside a Node. This is how the UI looks:

So the TouchScreenButtons are inside the UI, and then a Node2D -> the menu currently showing. Could it have something to do with the CanvasLayer?

I'm trying to get rid of the error just to not overload the output. I don't see this error having any impact on the performance, but I didn't look at any monitors.

Its possible that the canvas layer is causing the issue. Maybe it resets the input or somehow messes up how the TouchScreenButtons decide if they are visible or not. The problem here is that I'm not sure how to work around the CanvasLayer if it is causing the issue, outside of temporarily getting rid of it and seeing if that fixes the issue (I would highly suggest backing up your project beforehand if you decide to do this!)

Another thing I thought of after looking at the source is whether that the touch screen buttons that are not visible are still tracking input, since they use the _input function rather than the _unhandled_input function, and that is causing the error to print. If this is the case, then adding set_process_input(false) when making them invisible and set_process_input(true) when visible might solve the issue.

I tried to set_process_input(true/false) but I was still getting the error whenever I hover the mouse over the screen. I didn't yet change the CanvasLayer node, but what helped for now is that I've put this code in my TouchScreenButton.gd:

func _unhandled_input(event):
	if !enabled:
		return
	#my input check here

and I set my enabled variable when changing the menu (hiding one menu will 'disable' all it's buttons). This causes the old error to popup only when changing the menu, and only once for each button in new menu.

Considering the scenario I had up until now, this is great. I'll get back at you when I decide to try to change the CanvasLayer for something else and see if it works.

Thank you very much for helping me!

8 days later

Status report: in the end I made my own touch screen button using some sprites and _unhandled_input(event) to detect the touch (or click when mouse is emulating the touch), so there is no more error.

This is not to say the TouchScreenButton is bad in any way! It helped me a lot and it's definitely great when creating UI. I just like to do things my way, and Godot has me covered there, just like when I didn't want to use too much time to create a touchscreen button, with it's own TouchScreenButton node! :D

Well done Godot team! @TwistedTwigleg , thank you again for your support! gg wp

2 years later