I don’t know any programming but I’m trying to understand. Learning by doing and all that.
I’ve got a click action script that calls another script with a RemoveMe() function. I want to use IEnumerator to delay the dissapearence of the object with that RemoveMe() script on it. I’ve tried putting the following IEnumerator lines everywhere but I can’t figure out how to write it to make it work. This doesn’t work but it’s what I’ve got so far:
public class Destroyable : MonoBehaviour {
public void RemoveMe() {
IEnumerator MyMethod() {
yield return new WaitForSeconds(2);
Debug.Log("Destroyable's RemoveMe function is being called on" + name);
Destroy (gameObject);
}
}
}
Any help is greatly appreciated, thanks.