Search Unity

Games Help On Transferring From Pc Controls To Mobile Controls.

Discussion in 'Works In Progress - Archive' started by Jesscar97, Apr 14, 2019.

  1. Jesscar97

    Jesscar97

    Joined:
    Apr 11, 2019
    Posts:
    1
    Hey, I am new to this. I thought i might try and make an android game and release it in a few weeks. So, I have followed a tutorial online that made the type of game I wanted to make. I figured that it would be somewhat easy to change the controls from PC to Mobile. I was wrong. I have searched everywhere and I cannot find a way to convert my game to mobile. I downloaded a joystick and Lean Touch +, but I could not figure it out. The game is an endless runner and the character only moves up and down within a certain limit controlled by a swipe in the given direction. So, if I swipe up, then the player moves up. I need Help! I want to release this game in a few weeks! I'm freaking out!!


    public class Player : MonoBehaviour
    {
    private Vector2 targetPos;
    public float Yincrements;
    public float speed;
    public float maxHeight;
    public float minHeight;
    public Animator animator;
    public int health = 3;
    public Text healthDisplay;
    public GameObject gameOver;
    public GameObject popSound;
    private void Update()
    {
    healthDisplay.text = health.ToString();
    if (health <= 0)
    {
    gameOver.SetActive(true);
    Destroy(gameObject);
    }
    transform.position = Vector2.MoveTowards(transform.position, targetPos, speed * Time.deltaTime);
    if (Input.GetKeyDown(KeyCode.UpArrow) && transform.position.y < maxHeight)
    {
    Instantiate(popSound, transform.position, Quaternion.identity);
    animator.Play("PLayer_Fly_up");
    targetPos = new Vector2(transform.position.x, transform.position.y + Yincrements);
    }
    else if (Input.GetKeyDown(KeyCode.DownArrow) && transform.position.y > minHeight)
    {
    Instantiate(popSound, transform.position, Quaternion.identity);
    animator.Play("Player_Fly_down");
    targetPos = new Vector2(transform.position.x, transform.position.y - Yincrements);
    }
    }
    }