Hey guys. I want to create game on Android and when I put this script to the Main camera and start a game I can play, maybe a 10-15 seconds. After this time, displays a bluescreen.
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public class DestroyObjectesNormal : MonoBehaviour
{
public static int myScoreNormal = 10;
public static int myScoreKubekNormal = 5;
public static int HighscoresNormal=0;
public static bool isDeadNormal=false;
public AudioClip shootSound;
public AudioSource source;
public float volLowRange = .5f;
public float volHighRange = 1.0f;
public void awake()
{
source = GetComponent<AudioSource>();
}
/*void OnMouseDown()
{
isDead = true;
Destroy (this.gameObject);
Scoring ();
}*/
void Update() {
RaycastHit hit;
for (var i = 0; i < Input.touchCount; ++i) {
Ray ray = Camera.main.ScreenPointToRay (Input.GetTouch (i).position);
if (Input.GetTouch (i).phase == TouchPhase.Began)
if (Physics.Raycast (ray, out hit) && GameObject.FindGameObjectWithTag ("RollerBallNormal")) {
Destroy (hit.transform.gameObject);
ScoringHard();
isDeadNormal = true;
}
if (Physics.Raycast (ray, out hit) && GameObject.FindGameObjectWithTag("KubekNormal")) {
Destroy (hit.transform.gameObject);
ScoringKubekHard();
isDeadNormal = true;
}
}
//if (Input.GetButtonDown ("Fire1")) {
float vol = Random.Range (volLowRange, volHighRange);
if (isDeadNormal == true) {
//Scoring();
source.PlayOneShot (shootSound);
isDeadNormal = false;
}
}
public void ScoringHard() {
ScoreManagerNormal.scoreNormal += myScoreNormal;
}
public void ScoringKubekHard () {
ScoreManagerNormal.scoreNormal += myScoreNormal;
}
}