Question by
ActuallyHopper · Sep 04, 2015 at 12:46 PM ·
iosmobilephone
Touchscreen Controls
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;
}
}
Comment
Your answer
Follow this Question
Related Questions
do i need a mac to code upload an ios app? 1 Answer
Player animates with keyboard but not virtual joystick 0 Answers
Using Unity to build this ios project, Added google signin SDK 4.0.1 Framework, I get error 1 Answer
Unity IAP: Problem when submitting to iOS App Review. 1 Answer
iOS SocialPlatforms - IPv6 Support 1 Answer