I have a 2D top down game with a perfectly working movement system, however, I decided to switch to mobile, and faced a problem. I HAVE NO IDEA how to add add a Joystick (well, adding it is not that big of a deal) and connect it to my existing system.

Every tutorial out there is about implementing it from scratch.. What I thought was, you take a something like "Input.Joystick("Horizontal")" (NOT A REAL THING) and replace your Input.GetAxis with it. Apparently it's not that easy

Basically I need to move left ,right, up, down, control the mouse and shoot.

My movement code:


void Update()
    Vector2 moveInput = new Vector2(Input.GetAxisRaw("Horizontal"), Input.GetAxisRaw("Vertical"));
    moveAmount = moveInput.normalized * speed; 

private void FixedUpdate() {
    rb.MovePosition(rb.position + moveAmount * Time.fixedDeltaTime);


void Update()
    Vector2 direction = Camera.main.ScreenToWorldPoint(Input.mousePosition) - transform.position;
    float angle = Mathf.Atan2(direction.y, direction.x) * Mathf.Rad2Deg;
    Quaternion rotation = Quaternion.AngleAxis(angle - 90, Vector3.forward);
    transform.rotation = rotation;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.