game is working right in unity but does not work properly on the phone.
I am using target spawner. And it is work right in unity. but when i install game to my phone. spawner doesnt work right. it is just 2 enemy spawned and stop to spawn enemy. what is the reason of this ? Why code that works properly in unity but not work properly on the phone. here is my code. Thanks for your time..
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Target2Spawner : MonoBehaviour
{
public GameObject Target;
public GameObject Target2;
float randX;
float randY;
float randX2;
float randY2;
Vector2 whereToSpawn;
public float spawnRate;
public float spawnRate2;
float nextSpawn = 0.0f;
float nextSpawn2 = 0.0f;
// Start is called before the first frame update
void Start()
{
Destroy(Target, 2f);
}
// Update is called once per frame
void Update()
{
if (Time.time > nextSpawn)
{
nextSpawn = Time.time + spawnRate;
randX = Random.Range(-2f, 2f);
randY = Random.Range(0f, 5f);
whereToSpawn = new Vector2(randX, randY);
Instantiate(Target, whereToSpawn, Quaternion.identity);
Debug.Log("DFGHDFGHDFGHD");
}
if (ScoreScript.scoreValue > 10)
{
if (Time.time > nextSpawn2)
{
nextSpawn2 = Time.time + spawnRate2;
randX2 = Random.Range(-2f, 2f);
randY2 = Random.Range(2f, 5f);
if (randX != randX2 && randY != randY2)
{
whereToSpawn = new Vector2(randX2, randY2);
Instantiate(Target2, whereToSpawn, Quaternion.identity);
}
}
}
}
}
Comment
Your answer
Follow this Question
Related Questions
Andriod Gradle Build Field unity 2019 0 Answers
How to set box collider to a gizmos cube size 0 Answers
Semaphore Wait for signal Slows Down My Simple Android Game 0 Answers
Instanciated objects can only be seen if they were instanciated while looking to the left. 0 Answers
Input string was not in the correct format In new proyect 0 Answers