- Home /
Joystick GetAxisRaw
Hi,
Can someone please tell me how I would get the raw axis of my virtual Joystick in IOS like below please.
var movementJoystick : Joystick;
var v = Input.GetAxisRaw("Vertical");
var h = Input.GetAxisRaw("Horizontal");
Comment
I created a joystick for iphone but I did not use GetAxisRaw to define my axis. I used the Vector2 position of the joystick itself to define the axis. I'm assu$$anonymous$$g you just want to move left and right and that this is a 2D game? If so then give this a shot
Hi, thanks for that, but I went this way in the end.
function UpdateSmoothed$$anonymous$$ovementDirection ()
{
var cameraTransform = Camera.main.transform;
var movement : Vector3;
movement = movementJoystick.GetAxis();
// Forward vector relative to the camera along the x-z plane
var forward = cameraTransform.TransformDirection(Vector3.forward);
forward.y = 0;
forward = forward.normalized;
// Right vector relative to the camera
// Always orthogonal to the forward vector
var right = Vector3(forward.z, 0, -forward.x);
if(!keyboardEnabled && Input.GetAxisRaw("Vertical") || !keyboardEnabled && Input.GetAxisRaw("Horizontal")){
Debug.Log("$$anonymous$$eyboard NOT enabled");
}
if(keyboardEnabled){ // If keyboard is enabled
// Sets v and h to the keyboard vertical and horizontal inputs
v = Input.GetAxisRaw("Vertical");
h = Input.GetAxisRaw("Horizontal");
}
else
{
// Sets v and h to the Joystick vertical and horizontal inputs
v = movement.y;
h = movement.x;
}
Your answer
![](https://koobas.hobune.stream/wayback/20220613072843im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Joystick axes output wrong in 4.3.4 0 Answers
Inputmanager joystick axis alternative buttons 0 Answers
GameController Unity wrong Axis-Values 0 Answers
Custom Input manager problem 0 Answers
Get x/y joystick axis from hatswitch? 0 Answers