Hi all. What I am basically trying to do is take a bunch of functions out of one of my scripts and put them into their own script, basically turning them into my own little library. For the most part I have gotten this to work. The only thing I can't seem to get to work is the IEnumerator. I have figured out that I can't call it with StartCoroutine as that appears to be a non-static member trying to call a static member. I think I have the call right, the problem is the raycast inside of it. Since this script isn't attached to anything, I'm not 100% sure the raycast I have inside of it is doing anything. Any suggestions on the direction I should head in would be greatly appreciated. Code follows:
Coroutines actually run on MonoBehaviour instances, so you need to pass a reference of such an instance to your LoopThroughObjects function that is used to run the corouting on.
Besides that, watch out because "print" is only available in classes that derives from MonoBehaviour. I use always Debug.Log since it works everywhere.
It's no problem to call a static coroutine, but StartCoroutine is a member function of MonoBehaviour so you need an instance ;)
To call this function from another script (which is a true instance of a class that is derived from MonoBehaviour) do: