- Home /
Is there a substitution for GetKey() for a Gamepad controller in the Input Manager?
So in my game, I'm having this ball that's supposed to come flying towards the player whenever they hold down a button, continually adding a force to the ball towards the player as long as the player is holding down the button.
I was able to accomplish this using keyboard controls by just using GetKey, but I have absolutely no idea how to emulate this same effect for a gamepad controller. There are different options as to how the button on the controller should be interacted with, such as hold, tap, and press, but the problem for all of these is that it only applies the force to the ball once, no matter how long the player holds down the button, instead of continually adding that same force again and again while the player is holding the button down.
Is there any way to solve this?
Answer by bobbaluba · Feb 02, 2021 at 07:16 AM
If you're using the old (default) input system, then you probably want to use
Input.GetButton("Fire1");
"Fire1", "Fire2" and "Fire3" are configured by default by unity, and mapped to gamepad, mouse and keyboard buttons at the same time, but you can change that or add your own button names and mappings if you want.
https://docs.unity3d.com/ScriptReference/Input.html https://docs.unity3d.com/ScriptReference/Input.GetButton.html
Your answer
Follow this Question
Related Questions
is there any better way to move the character than rigidbody.addRelativeForce? 1 Answer
How do I add a jump function to my current script? 1 Answer
Using MoveTowards on button click 0 Answers
how i can make my player lose 1 live after HP = 0 ? 0 Answers
how to use right stc on gamepad like Input.mousePosition 0 Answers