Hi, I’m trying to call a IEnumerator function with StartCoroutine() but It is underlined in red and saying … The name ‘StartCoroutine’ does not exist in the current context. I have added and removed using System.Collections.Generic; using System.Collections; to try and get it to recognize it but still no joy, how can I call a IEnumerator function within a Behavior Tree script? Thanks.
OK, found the solution … here it is, hopefully it may help someone else out.
To start a coroutine within a Behaviour Tree script in Unity, you need to access the MonoBehaviour component attached to the GameObject that the Behaviour Tree is running on and use its StartCoroutine
method, passing in the coroutine function you’ve defined within your Behaviour Tree script as a parameter; essentially, treating the Behaviour Tree script as a regular MonoBehaviour when initiating a coroutine
1 Like
Hi @Griffo,
Glad that you found the solution!
I will link another user answer that I think might also be useful to you and other users looking to do something similar: Coroutines inside action nodes - #2 by Nobuna-no
Hope this helps
1 Like