Hi guys, I’m in the progress of creating my first 2D Game.
Since I’m both new to Unity and Android development I have some issues with Touch detection.
When I create a Rect with a height of 50px and a width of 100px, it seems as if the Rect is only registering Touch on the leftmost ~10px or so.
Here is my example code:
using UnityEngine;
using System.Collections;
public class StartUpScript : MonoBehaviour {
Rect buttonPLAY = new Rect(80, 340, 100, 50);
// Use this for initialization
void Start () {}
// Update is called once per frame
void Update () {
if (Input.touchCount > 0) {
if (buttonPLAY.Contains(Input.GetTouch(0).position)) {
Application.LoadLevel("GameScreen");
}
}
}
Also when it works, it feels kinda weird. As if he would fire events more than once or only if you press a certain amount of time. Is there another way to detect a single TAP anywhere on the specified Rect?
As I understand it, “Update” is called once per frame. Might this be the problem?
Thanks for the help