The title says it all pretty much, but I’ll elaborate a bit more here. I have this issue where the _input function isnt calling the code that i want when you just release the trigger when using a gamepad when connected to a phone. (I just wanted to add that it runs the action_just_pressed)
The weird thing is that it works as expected when testing the game on my computer with a controller. Has anyone else experienced this and is there a good way to fix it? Thank you very much.
1 Like
Can you paste the code? What happens versus what did you expect to happen?
here is an example:
if event.is_action_pressed("ZR") and Input.is_action_just_pressed("ZR") and !event.is_echo():
$Label.text = "pressed"
elif event.is_action_released("ZR") and Input.is_action_just_released("ZR") and !event.is_echo():
$Label.text = "released"
Well you probably don’t have to check for echos on release, but checking both event.is_action_released
and Input.is_action_just_released
could be a problem if the greater Input singleton isn’t synced with the function’s event. You should only be using the event
within the _input
or _unhandled_input
function.
Does this code work any better?
if event.is_action("ZR") and not event.is_echo():
$Label.text = "pressed" if event.is_pressed() else "released"
unfortunately no, that code only works on my pc as well
i also tried your recommendation of not checking for echo and its still not working.
Unfortunately however, checking that its not echo is core for my script because its used on my gun scirpt. and making sure that it’s not echo assures that the logic is only called once
(sorry, it seems that my previous reply wasn’t directly to your post)
I put this code in process for some testing:
$Label.text = str(Input.get_action_strength("ZR"))
What i found out was that the strength will go all the way up to 1 from zero, and then as i release pressure from the trigger it stops at 0.375. I’ve tested this with both an Xbox and a PS4 remote and still got the same result. But if i do the exact same test on my computer it goes all the way back to 0.
Im wondering if i should just increase the action’s deadzone
1 Like
Good testing, I guess the controller behaves a little differently for the phone. If you don’t care about the action strength, i.e. only using pressed/released then adjusting the deadzone to 0.5 or higher sounds good.
1 Like
I finally got it working, and im still able to use just_pressed/just_released. I set the deadzone to .51 and not it works.
Thank you for your time and help. perhaps this issue is something that needs fixed on Godot’s end.