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: Code (CSharp): 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.
I think it would be better if he started off with http://csharp.net-tutorials.com/basics/functions/ and http://msdn.microsoft.com/en-us/library/ms973875.aspx
While you definitely should read those links above, Destroy has a delay function build in.... http://docs.unity3d.com/ScriptReference/Object.Destroy.html
Thanks for the links, As Zaladur said Destroy has a delay function apparently. All I had to do for this issue was remove the IEnumerator code and write Destroy(gameObject, 3); to delay destroy 3 seconds But I appreciate the links, I will have to learn about IEnumerator and Coroutines at some point so I'm glad to have these links.