Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Input.action_just_pressed and Input.action_just_released doesnt work in _physics_process on Android #66318

Closed
ShadowwDev opened this issue Sep 23, 2022 · 16 comments · Fixed by #83301

Comments

@ShadowwDev
Copy link

Godot version

4.0.beta1

System information

Vulkan Android

Issue description

on Android with TouchScreenButton node, input_action_just_pressed and Input.action_just_released doesnt work in _physics_process function but it does work with _process function however.

This works on godot 3.5 so im guessing its a bug on godot 4 beta 1

Steps to reproduce

heres an example project with the details:
https://github.com/ShadowwDev/Godot4Beta1-InputBugTest

Minimal reproduction project

Project download
InputBugAndroid.zip

@aea0ccf9
Copy link

aea0ccf9 commented Oct 9, 2022

I can confirm this on 4.0.beta2.

@dannygaray60
Copy link

I was developing a project with Godot4 beta10 and ran into that same problem. When calling Input.is_action_just_pressed... on android it does not work if it is inside physics_process, it only works inside _process.

@clayjohn clayjohn modified the milestones: 4.0, 4.x Jan 26, 2023
@visionm45
Copy link

Confirmed bug in Godot 4.0

@ivandortulov
Copy link

This is still happening. Wish that it is fixed soon. The _process(delta) workaround does work.

@Calinou
Copy link
Member

Calinou commented May 3, 2023

On 4.0.2, this works on desktop when enabling Emulate Touch From Mouse in the advanced Project Settings, so the issue is Android-specific (or Android/iOS).

Can you reproduce this in any of the 4.0 alphas to determine when the regression started? I wonder if this was already present in 4.0.alpha1 or not, specifically.

@ehsanonline
Copy link

I'm using v4.0.1.stable.official [cacf49999] and Input.is_action_just_pressed and Input.is_action_just_released aren't working on android. I use them for jumping.

@visionm45
Copy link

try 4.0.2

@erniel
Copy link

erniel commented May 12, 2023

try 4.0.2

Still not working on android

@erniel
Copy link

erniel commented Jul 8, 2023

Confirmed bug in Godot 4.1

@idbrii
Copy link
Contributor

idbrii commented Oct 1, 2023

Is this issue because is_action_just_pressed checks if the input was pressed on this frame where each frame is a call to _process and not _physics_process? Maybe on Android, the framerate you're getting means that _physics_process isn't called frequently enough to hit the right frames when the input was changed (but on PC the framerate works out)?

@Alex2782
Copy link
Contributor

On 4.0.2, this works on desktop when enabling Emulate Touch From Mouse in the advanced Project Settings, so the issue is Android-specific (or Android/iOS).

Is the emulation started here? input.cpp#L502
TouchScreenButton events on Android here input.cpp#L858

I think because TouchScreenButton is a graphical element, the functions are only triggered after _physics_process.
Workaround: #83301 = get_physics_frames() + 1

I was going to compare it to a normal Button, but there is no action property. Docs
If it should be solved like with the TouchScreenButton, then you could probably reproduce the problem in the desktop version.

@lawnjelly
Copy link
Member

lawnjelly commented Oct 16, 2023

Sorry I must have missed this bug report.

It may be a regression from my PR #77055 .

EDIT: No it can't be, as my PR was from June 2023, and this report is from last year! 😁
However, there is a possibility my PR may have made this bug more likely to show up.

As @Alex2782 says, this is likely happening because the tick stored for the action is being stored after the physics_process. Their PR (#83301) to increase the physics tick registered for the press would likely "fix" the issue, but isn't ideal because it introduces a tick of delay to input, I'll put a note on that PR.

The actual problem makes total logical sense if you think about it. Every physics tick you have an opportunity to process presses that come in that tick. If the press comes in after the _physics_process, then it can be missed. This isn't occurring on most platforms as they process input synchronously before a tick, but on Android it can occur after (by random chance).

I think this should be pretty easy to fix properly, I'll do a PR. 👍

@synalice
Copy link
Contributor

Indeed, moving some of the Input code into the _process function fixed this issue for me. Thx ❤️
It really needs to be more clear what is going wrong. Something like debug warnings, idk.

@lawnjelly
Copy link
Member

Indeed, moving some of the Input code into the _process function fixed this issue for me. Thx ❤️
It really needs to be more clear what is going wrong. Something like debug warnings, idk.

The fault is not your side, it's an engine bug. There is PR to fix it, it just needs to be reviewed and merged. There's no point making a PR for warnings, as it is just as simple to fix it.

In some cases putting input code in the _process() can be used to mostly workaround it in the meantime (although even that appears to be susceptible, to a lesser extent).

@synalice
Copy link
Contributor

synalice commented Oct 19, 2023 via email

@Alex2782

This comment was marked as outdated.

@akien-mga akien-mga modified the milestones: 4.x, 4.2 Oct 24, 2023
YuriSizov pushed a commit to YuriSizov/godot that referenced this issue Oct 24, 2023
Notably fixes issues with `is_action_just_*` queries in `_physics_process`
for TouchScreenButton.

Fixes godotengine#66318.
Fixes godotengine#82396.

(cherry picked from commit 5137497)
orianbsilva pushed a commit to orianbsilva/godot that referenced this issue Nov 1, 2023
Notably fixes issues with `is_action_just_*` queries in `_physics_process`
for TouchScreenButton.

Fixes godotengine#66318.
Fixes godotengine#82396.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment