Joystick to control character movement

Control the character forward and backward, control the camera rotation left and right

public float walkSpeed;
public float rotationSpeed;

 

void OnJoystickMove( )
    {
        //获取摇杆的值
        float joyY = Input.GetAxis("Vertical") ;
        float joyX = Input.GetAxis("Horizontal");
        if (joyY != 0 || joyX != 0)
        {
            transform.Rotate(0, joyX* rotationSpeed, 0);
            joyY *= Time.deltaTime;
            transform.position += hdm.transform.forward * joyY * walkSpeed;
        }
    }

Guess you like

Origin blog.csdn.net/Abel02/article/details/120563305