- Home /
Map mobile joystick to Input.GetAxis("Horizontal") and "Vertical"
Hello, I am relatively new to unity. I am trying to convert a simple 3D game I made into mobile. I used Input.GetAxis for movement, "Horizontal" and "Vertical" for moving the camera object(first person game) and "Mouse X" and "Mouse Y" for camera pan/pitch. Right now using the standard mobile assets and dual joysticks they both seem to map "Mouse X" and "Mouse Y", I would like to map the left joystick to "Horizontal" and "Vertical". Is there a way to do this?
Answer by cariaga · Jan 16, 2015 at 06:30 PM
i know this is very old but here is what i did in order to map from negative to positive like -1 to 1 on both x and y axis
public Transform JoystickHandle;
public Transform JoystickBase;
public float H;
public float V;
void Update(){
H=JoystickHandle.position.x-JoystickBase.position.x;
V=JoystickHandle.position.y-JoystickBase.position.y;
}
JoystickHandle < the stick that i'm iterating with
JoystickBase < the center of the joystick
Your answer
Follow this Question
Related Questions
joystick movement 2 Answers
Input.GetAxis returning nonsensical values for HID Sensor/GameController 0 Answers
Joystick input Problem 3 Answers
Get DPad input value via GetButton instead of GetAxis? 8 Answers
Making one directional virtual joystick OR smoothly transitioning between buttons 0 Answers