Skip to content

Instantly share code, notes, and snippets.

@wuoix
Created January 17, 2015 20:34
Show Gist options
  • Save wuoix/2d2218978ac1fa6547c5 to your computer and use it in GitHub Desktop.
Save wuoix/2d2218978ac1fa6547c5 to your computer and use it in GitHub Desktop.
CubeSpawner
using UnityEngine;
using System.Collections;
public class CubeSpawner : MonoBehaviour {
public GameObject cube;
void Start() {
StartCoroutine(spawnCubes());
}
IEnumerator spawnCubes() {
while(true) {
yield return new WaitForSeconds(3.0f);
Instantiate (cube);
}
}
void Update() {
if (attack())
StartCoroutine (attackEnemies())
}
IEnumerator attackEnemies() {
Physics.OverlapSphere(transform.position, 25.0f);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment