I'm trying to set up a joystick control, but it's not working.
Below are the buttons I set up in Axis Input:
my code:
void FixedUpdate()
{
bool running = Input.GetKey(KeyCode.LeftShift);
//float h = Input.GetAxisRaw("Horizontal"); //keyboard
// float v = Input.GetAxisRaw("Vertical"); //keyboard
float h = Input.GetAxisRaw("LeftJoystickHorizontal");
float v = Input.GetAxisRaw("RightJoystickVertical");
bool isWalking = Mathf.Abs(h) + Mathf.Abs(v) > 0;
movement = ((running) ? runSpeed : walkSpeed) * new Vector3(h, 0.0f, v).normalized;
if (isWalking)
{
transform.position += movement * Time.fixedDeltaTime;
transform.LookAt(transform.position + movement);
}
But it is not working, the player moves only to one place. And I can not let the movements of the joystick with those of the keyboard. What am I doing so wrong?