Quantcast
Channel: Questions in topic: "error"
Viewing all articles
Browse latest Browse all 7934

WaitForSeconds...

$
0
0
I have had excruciating tries of finding a solution to this error, but I seem to find nothing. I have a simple cube prefab that spawns, and I want it to be destroyed after a three second delay. I used this: ----- using UnityEngine; using System.Collections; public class Cubes : MonoBehaviour { public float delay = 0.1f; public GameObject cube; public int destroyTimer = 3; void Start () { InvokeRepeating("Spawn", delay, delay); Destruction(); } void Spawn () { Instantiate(cube, new Vector3(Random.Range(-6, 6), 10, -2), Quaternion.identity); } void Destruction() { yield return new WaitForSeconds(destroyTimer); Destroy(gameObject); } } ----- I am getting the same stupid error over and over, no matter what I do. Here it is: "`Assets/Cubes.cs(18,14): error CS1624: The body of `Cubes.Destruction()' cannot be an iterator block because `void' is not an iterator interface type`" Can anyone help me out? Thanks in advance!

Viewing all articles
Browse latest Browse all 7934

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>