Input action is not consistently activated when using is_action_pressed()

Godot Version

v3.5.2.stable.fedora [170ba337a]

Question

I tried following a tutorial, which instructed me to create an input action called ui_touch, that includes “All Devices, Left Button”. This is the function relating to the action:

func _on_input_event(_viewport, event, _shape_idx) -> void:
	if event.is_action_pressed("ui_touch"):
		print("ui_touch triggered")
		touch_down = true
		position_start = event.position

Unfortunately, when I test the scene, the action doesn’t get triggered every time I left-click. I added the print() to debug, and it indeed doesn’t print most of the time when I left-click. There doesn’t seem to be any rule regarding when it is triggered.

I’d love help. Thank you.

One thing to keep in mind is that I think ‘ui_touch’ is a editor input action. You should define your own as this could be set as “handled” by the input stack, or editor, and not propagate down to your collision shape.

If the input is not consumed by anyone else then a ray is cast from the camera into the scene and your collision shape must be big enough to collide readily with the ray.

You can turn on collision shape wires in the debugging menu to see where you should be clicking.

If there are other shapes that could be in the way you should remove the “ray pickable” option as you see fit.

So… rename the action? I’m a novice, this is a bit complicated for me.

Make a new one, go to the project settings and then to the input map tab and create a new action.

It could be possible that the built-in action is fine have you tried the other suggestions?

I deleted it and created an identical action with no ui_. The issue persists.

Is your collision shape (area, static or rigid body) ray pickable enabled?