You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
on_input is called every frame while a bound key is held, but it should only be called when the key is pressed, repeated, or released.
To Reproduce (REQUIRED)
Create an empty project
add one key to the input binding and remove the mouse binding
add a single game object
create and add a script to the game object
paste this code into the script
function init(self)
msg.post(".", "acquire_input_focus")
end
function on_input(self, action_id, action)
print(action_id, "pressed:", action.pressed, "released:", action.released)
end
Run the app
press and hold the bound key
Look at the console output to see bug being demonstrated
Expected behavior (REQUIRED)
You should see just one line of output in the console: DEBUG:SCRIPT: hash: [my_action] pressed: true released: false
Actual behavior
You see the expected line in the console, then another line getting repeated every frame: DEBUG:SCRIPT: hash: [my_action] pressed: true released: false [n++] DEBUG:SCRIPT: hash: [my_action] pressed: false released: false
Defold version (REQUIRED):
1.8.0
Platforms (REQUIRED):
macOS Sonoma 14.4.1
Mac
Minimal repro case project (OPTIONAL): input_bug.zip
The text was updated successfully, but these errors were encountered:
Ah, no, the pressed and released states happen only once on the frame when the input was first pressed or released. It will not repeat. Note that there is also a repeated state which will be triggered at the configured Repeat Interval
I think this was closed without understanding the issue/report. Perhaps images will help so that you don't have to run the minimal repro project.
With a slightly modified print statement to include repeat state: print(action_id, "pressed:", action.pressed, "released:", action.released, "repeated:", action.repeated)
Expected result (as per documentation):
Pressing a key, holding it until it repeats twice (0.5s + 0.2s + 0.2s) then releasing it before the next repeat should give exactly 4 calls to on_input as per the documentation and "simulated" in the above image.
Actual Result:
Here, on_input is called 49 times. The expected 4 plus 45 spurious calls where no event happened (all flags are false).
Describe the bug (REQUIRED)
on_input
is called every frame while a bound key is held, but it should only be called when the key is pressed, repeated, or released.To Reproduce (REQUIRED)
Expected behavior (REQUIRED)
You should see just one line of output in the console:
DEBUG:SCRIPT: hash: [my_action] pressed: true released: false
Actual behavior
You see the expected line in the console, then another line getting repeated every frame:
DEBUG:SCRIPT: hash: [my_action] pressed: true released: false
[n++] DEBUG:SCRIPT: hash: [my_action] pressed: false released: false
Defold version (REQUIRED):
Platforms (REQUIRED):
Minimal repro case project (OPTIONAL):
input_bug.zip
The text was updated successfully, but these errors were encountered: