Created
January 17, 2015 20:34
-
-
Save wuoix/2d2218978ac1fa6547c5 to your computer and use it in GitHub Desktop.
CubeSpawner
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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