- Home /
Spawn Script not working on Iphone.
So I have the script below. It works fine when i test it on my game, on my computer. But when I put it on an actual Iphone it stops spawning completely.
What I am looking for is I have 4 things that need to be spawned randomly it does not matter which one comes first. And as the time goes by for them to be spawned faster. More time more objects less time less objects. The problem once again is that it works on my computer but does not work on the Iphone. Any suggestions?
// SPAWNER // the object we want to spawn var prefabToSpawn:Transform; var prefabToSpawn1:Transform; var prefabToSpawn2:Transform; var prefabToSpawn3:Transform;
/*var redBtn:Transform; var yellowBtn:Transform; var greenBtn:Transform; var blueBtn:Transform; blueBtn.transform.position.y = 4; blueBtn.transform.position.x = -13;
var blueExplosion:Transform; */ // how long to wait between spawns var spawnTime:int ; // the amount of random time in each spawn cycle delay // the timer private var spawnTimer:int; var x:int=2; function Awake() { // initialize our timer ResetSpawnTimer(x); }
function Update(){ // count the timer down at the rate the game is updating spawnTimer -= Time.deltaTime;
// if we've hit or passed zero
if(spawnTimer == 0.0){
// create the object from our prefab blueprint
spawnTimer = ResetSpawnTimer(x);
Debug.Log(spawnTimer);
if(spawnTimer<75){
Instantiate(prefabToSpawn, transform.position, Quaternion.identity);
}else if (spawnTimer>76 && spawnTimer<150){
Instantiate(prefabToSpawn1, transform.position, Quaternion.identity);
}else if(spawnTimer>151 && spawnTimer<225){
Instantiate(prefabToSpawn2, transform.position, Quaternion.identity);
}else if(spawnTimer>226 && spawnTimer<300){
Instantiate(prefabToSpawn3, transform.position, Quaternion.identity);
}
// tell the timer to reset so we can count down again
ResetSpawnTimer(x);
}
}
function ResetSpawnTimer(x) { // initialize spawn timer with randomness spawnTimer = Random.Range(0, 300); spawntime = spawnTime + 1; return spawnTimer; }
answers.unity3d.com/questions/4685/ sounds like the same problem =).
Your answer
Follow this Question
Related Questions
Random Spawning 1 Answer
simplified spawn script? 1 Answer
How to set up random spawnpoints? 1 Answer
Room generator spawn 1 unique room 1 Answer
How do I make a game object spawn several times in semi-random locations? 1 Answer