I want to spawn a prefab after 2 seconds but I am having an issue with my yield function, here is the code:
using UnityEngine;
using System.Collections;
public class spawn : MonoBehaviour
{
// Prefab to spawn
public int distance = 10;
public int timeDelay = 5;
public float speed = 0.1f;
public Transform clone;
public GameObject spawnPoint;
// Use this for initialization
void Start()
{
}
void Update()
{
transform.position += transform.forward * distance * speed;
while (true)
{
//My yield is showing up in red giving me an error
yield WaitForSeconds(timeDelay);
Instantiate (clone, spawnPoint.transform.position, spawnPoint.transform.rotation);
}
}
}
This is what the console returns:
Am i doing something wrong here?