Skip to content

Instantly share code, notes, and snippets.

@TheCuttlefish
Last active November 14, 2019 13:23
Show Gist options
  • Save TheCuttlefish/6eeb0877ff82104e66133dfa5544a537 to your computer and use it in GitHub Desktop.
Save TheCuttlefish/6eeb0877ff82104e66133dfa5544a537 to your computer and use it in GitHub Desktop.
Basic Spawn
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Spawner : MonoBehaviour {
int spawnCounter = 0;
void Update () {
spawnCounter+= 1;
if(spawnCounter > 100){
//spawn your object here!!
spawnCounter = 0;
}
}
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class SpawnerRandom : MonoBehaviour {
int spawnCounter = 0;
void Update () {
spawnCounter += 1;
if (spawnCounter > 100) {
//spawn your object here!!
spawnCounter = Random.Range (-10, 10);
}
}
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class SpawnerRandom2 : MonoBehaviour {
int spawnCounter = 0;
void Update () {
RandomSpawner ();
}
void RandomSpawner () {
spawnCounter += 1;
if (spawnCounter > 100) {
//spawn your object here!!
spawnCounter = Random.Range (-10, 10);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment