I am fairly new to unity and i would like some help implementing touch screen controls into my game. It is a simple brick breaker game and i would like the touchscreen controls to move the paddle and to fire the ball as well. I would like it to work on IOS ( If the script matters, I'm not too sure). Any help would be greatly appreciated, Thanks.
Here is the current script that i am using for the paddle:
using UnityEngine;
using System.Collections;
public class Paddle : MonoBehaviour {
public float paddleSpeed = 1f;
private Vector3 playerPos = new Vector3 (0, -9.5f, 0);
void Update ()
{
float xPos = transform.position.x + (Input.GetAxis("Horizontal") * paddleSpeed);
playerPos = new Vector3 (Mathf.Clamp (xPos, -8f, 8f), -9.5f, 0f);
transform.position = playerPos;
}
}
↧