For future reference, I want to say that I found a pretty cool coroutine wrapper already scripted that allows you to check if a coroutine is finished, if it's running, etc. You can also pause the execution.
It's in this thread, you just need to create a script and add it to your project:
Example of use in a BT task (you just need to put change your coroutine's name):
[RequiredField]
public SharedMyCharacter myCharacterScript;
private Task t;
public override void OnStart()
{
t = new Task(myCharacterScript.Value.myCoroutine());
}
public override TaskStatus OnUpdate()
{
if (t.Running) { return TaskStatus.Running; }
else
{
return TaskStatus.Success;
}
This is pretty good for me, as I believe that it's better to just code coroutines and have my BT Task's calling those... also, I already have many coroutines that I want to use inside my tree without having to re-write them. Coroutines are a bit more intuitive to me, and I can make a snippet to write the BT tasks in two clicks just changing the coroutine's name. That way I seldom have to worry about creating shared variables, and recoverying a character's script value and some other stuff. It just helps with the learning curve. It seems a bit more compatible too as my actions are coroutines accesible to any script outside of the BT scope.
I specially like this for bigger blocks of actions that you know are solid. Actions like say "enter cover" that require a bunch of steps like walk to a point, wait till the guy reaches, then crouch, wait for the animation and then set a bool in the animator and wait till the cover pose has been reached. Better to have this blocks that won't change and don't need visual debugging than a million nodes that will convolute the BT. And still you can visually see what's happening and leave the BT for what it should be.
Justin, maybe you should consider adding this code to your package, I think we can all benefit from it.
Anyway, thanks.