I think it would be better if you try to achieve what you want by using some sort of static events, in which the ActionTask can subscribe to instead of trying to get a reference to the action task object itself.
Here is a very rough example of what I mean:
1
2
3
4
5
6
7
8
9
10
11
12
publicclassExample:MonoBehaviour{
publicstaticeventAction onMoveOn;
publicstaticvoidMoveOn(){
if(onMoveOn!=null){
onMoveOn();
}
}
}
You could also turn the above example into some kind of a “manager” if you’d like.
Then in your action tasks, you could subscribe to the event in the OnExecute method like this:
1
2
3
Example.onMoveOn+=()=>{EndAction();}
This way, and by using events in general, you don’t have to worry about referencing everything. 🙂
Let me know if that works for you.
Thanks.
Join us on Discord: https://discord.gg/97q2Rjh
Login
Register
By registering on this website you agree to our Privacy Policy.