- Home /
gamepad controls
I'm currently trying to program controls for my gamepad controller but am having issues finding enough information to program what I'm trying to do. I have changed the input to be setup to work with my logitech duel analog controller but just can't get it to work. I'm trying to get my character to move around using the left analog stick and simply move around said character with the right analog stick. If anyone has example code or anything that could help that would be amazing !
similar to this movement but using javascript and a gamepad controller.
Could you please elaborate a little? I'm not sure what the problem is here! Are you having trouble reading from the analog sticks, or are you having trouble using the values once you have them?
I'm having trouble figuring out how to code the controls so that your able to use the analog stick to move around. I understand how to use keyboard / mouse input but not gamepad input for coding. I was trying to get my character to move around using the left analog stick similar to how the character in the angry bots unity demo or another game like metal gear solid movement.
I'm unsure on how the coding would work. Thinking something like...
If(leftAnalogStick > 0 ) {
character.direction = leftAnalogStick.direction;
character.speed = 20;
}
Is "leftAnalogStick" returning any value? The problem can either be the input not being read or the input is valid but it's not applied correctly to your character.
The code I posted is an example of kind of what I want it to do. I know it's all incorrect because I am unsure how to code analog controls.
Answer by Eric5h5 · Nov 16, 2011 at 05:55 PM
Use Input.GetAxis, and set up the axes in the input manager.
I've setup all the controls in the input editor but I'm not sure how to program the controls into my game.
Did you read the docs for GetAxis? There's sample code for moving an object around.
I've tried code from the documentation but none of it seems to effect my game. I setup the joystick controls in the input manager but all it does is move my character forward and back with the left analog and rotates my character with the right. What I'm trying to do is add rotation + movement to the left analog and move the camera with the right.
Your answer
Follow this Question
Related Questions
Use Gamepad right analog stick instead of mouse to control crosshair movement 3 Answers
Android multiple gamepad/controller/joystick support? 1 Answer
Keyboard/Joystick Inputs Do Not Work until Mouse Clicked 0 Answers
Is there a way to fire the inspector events from code? 0 Answers
Mayflash Gamecube controller vibration 0 Answers