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

TouchScreenButton with is_action_just_pressed() bug #82396

Closed
RoboLampDev opened this issue Sep 26, 2023 · 19 comments · Fixed by #83301
Closed

TouchScreenButton with is_action_just_pressed() bug #82396

RoboLampDev opened this issue Sep 26, 2023 · 19 comments · Fixed by #83301

Comments

@RoboLampDev
Copy link

Godot version

4.1.2.rc1

System information

Godot v4.1.2.rc1 - Windows 10.0.19045 - Vulkan (Mobile) - integrated AMD Radeon(TM) Vega 8 Graphics () - AMD Ryzen 3 2200G with Radeon Vega Graphics (4 Threads)

Issue description

if Input.is_action_just_pressed("ui_accept") and is_on_floor():     

this form with "just" don't work on mobile (android)
i don't know why but when you try it in pc with mouse emulate touch it works fine but when you export the project to the mobile it don't work although is_action_pressed() works fine idk why the one with "just" don't work with TouchScreenButton on mobile please fix that

Steps to reproduce

if Input.is_action_just_pressed("ui_accept") and is_on_floor(): velocity.y = JUMP_VELOCITY

its a basic form of jump when you add TouchScreenButton and assign it with ui_accept and try it it only works in pc not actually on the mobile i cant just the Button dont work
things to note :
-TouchScreenButton work with is_action_pressed() on mobile but is_action_just_pressed() don't work
-is_action_just_pressed() work fine in pc when you click with the mouse but it don't work on mobile
-It only work on mobile if you make a signals for pressed and released for TouchScreenButton

Minimal reproduction project

image

@Sauermann
Copy link
Contributor

Can you please check,if this is a duplicate of #58562?

@RoboLampDev
Copy link
Author

RoboLampDev commented Sep 26, 2023 via email

@ErezShahaf
Copy link
Contributor

ErezShahaf commented Sep 27, 2023

Hey, can you please upload the minimal reproduction project? (You have uploaded an image, and not a link to the project)
I'd love to see what you did there and investigate it.

@RoboLampDev
Copy link
Author

Sure, no problem. ​
here it is . i also included apk file so you can install it on your mobile and test it
https://drive.google.com/file/d/11mMZFGXq7ahLPzTiTHSFZq39r0WzEyWj/view?usp=drive_link

@Alex2782
Copy link
Contributor

Alex2782 commented Oct 4, 2023

@RoboLampDev
please adjust your "minimal reproduction project" in the first post here at Github (remove screenshot). For your Google Drive share a permission is necessary.

@Jedzkie
Copy link

Jedzkie commented Oct 9, 2023

I'm experiencing the same issue.

Here's my minimal project: TouchScreenButtonBugMobile.zip

@Alex2782 @ErezShahaf

@Alex2782
Copy link
Contributor

Alex2782 commented Oct 10, 2023

I'm experiencing the same issue.

Here's my minimal project: TouchScreenButtonBugMobile.zip

v4.2.dev6.official [57a6813]
I couldn't reproduce the problem, maybe already fixed?

exported APK (20 MB, my Google Drive-Account): TouchScreenButton.apk

Small error I could find, however, now and then the counter was not increased, but most of the time it was.
I could first check if TouchScreenButton always detects touch event at all.

func _physics_process(_delta : float) -> void:
	if Input.is_action_just_pressed('touch_me'):
		pressed_count += 1
		$Label.text = 'Pressed: %s' % pressed_count

@Jedzkie
Copy link

Jedzkie commented Oct 10, 2023

I'm experiencing the same issue.
Here's my minimal project: TouchScreenButtonBugMobile.zip

v4.2.dev6.official [57a6813] I couldn't reproduce the problem, maybe already fixed?

exported APK (20 MB, my Google Drive-Account): TouchScreenButton.apk

Small error I could find, however, now and then the counter was not increased, but most of the time it was. I could first check if TouchScreenButton always detects touch event at all.

func _physics_process(_delta : float) -> void:
	if Input.is_action_just_pressed('touch_me'):
		pressed_count += 1
		$Label.text = 'Pressed: %s' % pressed_count

I tried your exported apk, and the touch event is still not working.

@Alex2782
Copy link
Contributor

on Android 13 Samsung tablet it works 90%, where did you test?

image

@Jedzkie
Copy link

Jedzkie commented Oct 11, 2023

on Android 13 Samsung tablet it works 90%, where did you test?

image

Tested in my xiaomi mi max 2 and samsung galaxy note 8

@Alex2782
Copy link
Contributor

on my Pixel 4a it doesn't work either, I think the button is too small.
I'll try to debug it in the next days when I find time

@Jedzkie
Copy link

Jedzkie commented Oct 11, 2023

on my Pixel 4a it doesn't work either, I think the button is too small. I'll try to debug it in the next days when I find time

Alright man. One thing I notice that if you use _process instead of _physics_process. The Input.is_action_just_pressed works.

@Alex2782
Copy link
Contributor

new "APK" (old file replaced), bigger button does not work either (_physics_process)

@Jedzkie
Copy link

Jedzkie commented Oct 11, 2023

I just tested in v4.0-alpha1, it's not working either. Maybe we must look what commit broke it.

@Jedzkie
Copy link

Jedzkie commented Oct 11, 2023

I think this might help.
#58562 (comment)

@Alex2782
Copy link
Contributor

On my tablet (Samsung SM-T870) I can always reproduce the problem with 30 fps.
Engine.max_fps = 30
If I do not adjust the max_fps (default) then it works 40% of the time.

following condition is always false because Engine::get_singleton()->get_physics_frames() is 1 frame ahead

return pressed_requirement && E->value.pressed_physics_frame == Engine::get_singleton()->get_physics_frames();

print_line / logcat debug

2023-10-13 17:43:07.759 18401-18445 godot  I  Input::action_press -> action.pressed_physics_frame: 38
2023-10-13 17:43:07.760 18401-18445 godot  I  Engine::get_singleton()->_physics_frames++;
2023-10-13 17:43:07.959 18401-18445 godot  I  pressed_physics_frame: 38 get_physics_frames: 39

fps config

	Engine.max_physics_steps_per_frame = 1
	Engine.max_fps = 5

@ChickensioDev
Copy link

on my Pixel 4a it doesn't work either, I think the button is too small. I'll try to debug it in the next days when I find time

Alright man. One thing I notice that if you use _process instead of _physics_process. The Input.is_action_just_pressed works.

this is exactly what im facing too

@akien-mga akien-mga added this to the 4.2 milestone Oct 24, 2023
@Jedzkie
Copy link

Jedzkie commented Oct 24, 2023

Thank you for fixing this issue @Alex2782

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.
@luiscesjr
Copy link

I'm facing a similar issue right now on 4.2.2 Mono. I did not test this further into 4.3 beta since this is closed since Nov 2023 I figured it will probably be the same there.
I am play testing this on my PC, did not try yet on mobile to see if it would have a different result.

What happens is, I just set a new action on the Input settings and added it to my button as follows:

image
(Don't mind the physical key there, it's just for testing)

And here is my Touch Screen Button:

image

And here is my simple code:

image

This print is unreachable. Either with pressed or just pressed it won't happen at all.
This happens both in Physics process and in Process.

First I found out about this issue when searching for my problem: #58562

To further test this I created a clean project, made a simple scene like this:

image

And the script attached should do this:

image

But this also did not work, and did not print anything at all.

I'm not sure I missed anything, but I guess that's all!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants