I have a script where on collision it set itself to false. This works fine, but when I try to tell it to call Emotes.Hearts(); from my Emote script I get this error:
Assets/Scripts/Emotes.cs(11,21): error CS1624: The body of `Emotes.Hearts()' cannot be an iterator block because `void' is not an iterator interface type
Here’s my class attached to Fruit:
using UnityEngine;
using System.Collections;
public class Fruit : MonoBehaviour {
private Emotes emotes;
void Start(){
_HpMax = 200;
_HpCur = 1;
}
void OnTriggerEnter(Collider other){
if (other.gameObject.tag == "Player"){
gameObject.SetActive(false);
emotes.Hearts();
}
//Destroy(gameObject);
}
}
}
And here’s a bit of my Emotes (took all ten different types out to save on room, set up the same for each.)
using UnityEngine;
using System.Collections;
public class Emotes : MonoBehaviour {
public GameObject _floatinghearts;
void Awake(){
_floatinghearts.active = false;
}
public IEnumerator Hearts(){
_floatinghearts.active = true;
yield return new WaitForSeconds (1);
_floatinghearts.active = false;
}
}