I'm trying to force Unity to spawn a gameobject every second with a coroutine but I am getting the errors cs1502 & cs1503. (sorry if this is a stupid syntax error)
public class BossCannon : MonoBehaviour
{
public BossBullet BossAmmo;
public float Force;
public bool trigger = false;
void Start ()
{
}
void Update()
{
if (trigger == true)
ShootBullet();
}
void ShotPattern()
{
while (true)
{
StartCoroutine(Shoot);
}
}
public IEnumerator Shoot()
{
trigger = false;
yield return new WaitForSeconds(1f); //Waits 1 second
GameObject b = Instantiate(BossAmmo.gameObject, transform.position, transform.rotation) as GameObject;
trigger = true;
}
}
Try passing the Transform to Instantiate instead of the GameObject.
You are also starting your coroutine wrong. Try this:
The errors you are getting are Invalid Parameter errors. A method is expecting one type, and you are passing another type.
It might be helpful to post the full errors you are getting when you compile.
One more note: while(true) is generally a terrible thing to do. When you do get this running, I suspect Unity will suddenly lock up on you.