Tap to start implementation
Hi, I'm trying to implement a tap to start feature for my game when it begins. The game itself uses touch for the actual game mechanics so it isn't unique to starting the game alone. My issue is, I can't seem to find a function that gets me the total number of taps that have occurred. I tried using while loops, to add up a counter, however my unity kept crashing I believe due to an infinite loop. My current code is as follows
using UnityEngine;
using System.Collections;
public class ScoreManger : MonoBehaviour {
public static int Score = 0;
public GUISkin layout;
bool gameStart;
// Use this for initialization
void Start () {
gameStart = false;
Time.timeScale = 0;
}
// Update is called once per frame
void Update() {
}
void OnGUI () {
GUI.skin = layout;
if (Input.touchCount > 0) {// Someone has touched.
gameStart = true;
Time.timeScale = 1;
GUI.Label(new Rect(Screen.width / 2 - 90 - 12, 100, 100, 100), "" + Score); // Displays score counter.
}
else {
// gameStart is still false
GUI.Label(new Rect(Screen.width / 2 - 50 - 12, 100, 100, 100), "Tap to Start");// Tap to Start
}
}
}
Currently inside my if statements I'm using input.touchCount which gives me the current amount of fingers touching the screen not the total amount so far which is what I thought it was. I'm not too sure how to proceed with fixing it.
Your answer
![](https://koobas.hobune.stream/wayback/20220612074019im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Hi everyone! The event of touching the display of phone doesn't work sometimes. 0 Answers
Detect how long a tap is held 1 Answer
difficulty in detecting multi touch 1 Answer
destroy gameObject on touch 0 Answers
TouchScript Library - Continually (by frame or change of position) get touch position 0 Answers