Example of handling gamepad triggers (L/R) as input action?

Godot Version

4.2.1

Question

Hey everyone,
I’m aware that the analog triggers on most game pads are handled as input axes.
Could someone show me an example on how to handle these for a single input action?
E.g. like most first person shooters handle gun firing? Player taps the right trigger and it shoots?

Thanks in advance!

Go to project settings > Input Map and set an input action for both L and R triggers.

Assuming you set an action for the R trigger name “RightShoulder” this is how you’ll use it in your code

func input(event):
   If Input.is_action_just_pressed("RightShoulder"):
        ##Shoot projectile

Thank you, this worked perfectly!

Just adding this info on what I initially did wrong on my end which caused multiple triggers:

  • I read out event instead of Input directly.
  • I used is_action_pressed instead of is_action_just_pressed
2 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.