Godot: Input.action_press doesn't work

Created on 6 Oct 2017  路  2Comments  路  Source: godotengine/godot

Operating system or device, Godot version, GPU Model and driver (if graphics related):
Windows 10 64bit - Godot 3.0 build from yesterday

Issue description:
Using Input.action_press() doesn't seem to work.

Steps to reproduce:
I made a scene with a button, the button pressed was connected to a node with this script:

extends Node

func _input(event):
    if event.is_action_pressed("ui_cancel"):
        print("Test")

func _on_Button_pressed():
    Input.action_press("ui_cancel")

Pressing the default "ui_cancel" key will print "Test", but pressing the button will not print anything. I also tried with _unhandled_input(event), but that didn't work either.

documentation enhancement core input

Most helpful comment

Seems like Input.action_press doesn't invoke _input. Not sure if intended. Have you tried with 2.1?

My workaround is to use Input.parse_input_event:

    var a = InputEventAction.new()
    a.action = "ui_cancel"
    a.pressed = true
    Input.parse_input_event(a)

(If you use is_action_pressed after action_press, it'll correctly return true.)

All 2 comments

Seems like Input.action_press doesn't invoke _input. Not sure if intended. Have you tried with 2.1?

My workaround is to use Input.parse_input_event:

    var a = InputEventAction.new()
    a.action = "ui_cancel"
    a.pressed = true
    Input.parse_input_event(a)

(If you use is_action_pressed after action_press, it'll correctly return true.)

Ah alright, if this is working as intended maybe the documentation should mention that it wont actually call _input

Was this page helpful?
0 / 5 - 0 ratings