So right now I have enemies that spawn behind objects with a delay.
What I need is to display an image on the screen 5 seconds after each enemy spawns (it's to show the player it has been "attacked") and that image has to disappear after like 2 seconds so.
I know I have to use WaitForSeconds
but I don't know how because everything I've tried isn't working.
Here's my code:
public class TimedSpawn : MonoBehaviour {
public GameObject spawnee;
public bool stopSpawning;
public float spawnTime;
public float spawnDelay;
// Use this for initialization
void Start () {
InvokeRepeating ("SpawnObject", spawnTime, spawnDelay);
}
public void SpawnObject (){
Instantiate (spawnee, transform.position, transform.rotation);
if (stopSpawning) {
CancelInvoke ("SpawnObject");
}
}
}
No comments:
Post a Comment