I have issue with mobile touch control

Hi i just started making my first game in unity 5 on android. I working on game pong

and i want use mobile DualTouchControls only move touch area. But i´m begginer and i dont now how to control Padle what i created on android.On pc i can control my padle with ↑ and ↓ . I don´t now how to code script to make my padle move vertical when i touch the screen in my mobile (android).This is padle script:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Padle : MonoBehaviour {

public float paddleSpeed = 1;
public Vector3 playerPos;

void Update ()
{
float yPos=gameObject.transform.position.y + (Input.GetAxis(“Vertical”) * paddleSpeed);
playerPos=new Vector3 (-20,Mathf.Clamp(yPos, -12.0f, 12.5f),0);
gameObject.transform.position=playerPos;
}
}

BTW SORRY FOR MY ENGLISH NOt MY NATIVE LANGUAGE :slight_smile:

2963397–220033–Padle.cs (806 Bytes)

Please use code tags when you post code; it makes it much easier to read.

To do this, you will iterate over Input.touches, and move the paddle towards the touch position (for any touch on the correct side of the screen). Something like this (rough, untested code):

void Update() {
    foreach (Touch touch in Input.touches) {
        // Get the position of the touch, in screen coordinates
        Vector3 touchPos = touch.position;
       
        // Convert that to world coordinates
        touchPos.z = Mathf.Abs(Camera.position.z);
        Vector3 hitPos = Camera.main.ScreenToWorldPoint(touchPos);
       
        // ignore this touch if it's on the wrong side of the screen!
        if (hitPos.x < 0) continue;
       
        // Now, move our transform towards the position hit (in Y only).
        Vector3 myPos = transform.position;
        myPos.y = Mathf.MoveTowards(myPos.y, hitPos.y, paddleSpeed * Time.deltaTime);
        transform.position = myPos;
    }
}

NOTE: In your code, you forgot to multiply paddleSpeed by Time.deltaTime. This is very important; otherwise the actual speed will vary with the frame rate. To get a constant speed, use paddleSpeed * Time.deltaTime. But this means you will need to increase your paddleSpeed value by a factor of 50 or 60 (that is, initialize paddleSpeed to 60 instead of 1).

Still not working on my mobile . I can´t move padle vertical.

You’ll have to debug it then. My post was just example code to get you started.

Okey i try. Thanks for help

And i have problem with unity remote 5 on android. When i input usb in my notebook and try play game nothing happened. I edit on editor setthings i enable mobile input but still nothing happened. I dont now why.