How to make an invisible area for the android on the screen (the right half of the screen is the left half of the screen), by tapping on which you can call the necessary script (i.e. to control the GO). This script is not working here.
using UnityEngine; using System.Collections; public class controler : MonoBehaviour { public GameObject player; private Touch touch; void Update() { int fingerCount = 0; foreach (Touch touch in Input.touches) { if (touch.phase != TouchPhase.Ended && touch.phase != TouchPhase.Canceled) fingerCount++; } if (fingerCount > 0) { if (touch.position.x < (Screen.width / 2)) player.transform.rotation = Quaternion.Euler(0, transform.rotation.eulerAngles.y - 90f, 0); } else player.transform.rotation = Quaternion.Euler(0, transform.rotation.eulerAngles.y + 90f, 0); } } Why, what is not right? Thank you all.