[Closed] BTNodes, Delegates, and BTNodeMemory
So we've been running into an issue over and over. We will make a BTNode (Task, Service, or Decorator) and make a memory for it, since it's not instanced. No problems there. But if we want that node to respond to a delegate from another system and store that info in BTMemory, that's where things tend to go down hill.
If we bind a function from our BTNode, to the delegate and it gets called. We have no access to the BTMemory. The other examples we've seen and have this issue, happen to have the data required to access the BTMemory passed into the delegate. Not all delegates are going to have the information required to get that memory. And we shouldn't be changing other systems to make sure its delegates pass information we need to work.
What I'm trying to do (but its turning into a mess) is allow the BTMemory to have a "delegate handler object" with a function that we can use to bind too. This handler can also store information we can use to get our memory. Using the EQS service as an example, I'm going to get the memory using this:
So I need to store the BTComp and my BTNode! Which is just gross:/ I could also just make it instanced, but it seems like the BT system would rather I not do that.
My questions are:
The question has been closed May 31 '16 at 06:35 PM by AndrewHurley for the following reason:
The question is answered, right answer was accepted
There's a really cool feature UE4 delegates have that allows you to pass in some payload when binding to a delegate, and that could be a generic solution you're looking for here.
The way it works is you implement a function with a signature required by the delegate you want to bind to, and then append extra parameters you need. And then, when you bind to a delegate you simply specify values of the params the delegate doesn't support on it's own.
Code say a 1k words, I mean something like this:
In your case I'd suggest using
My mind was blown when I've learned about it, hope yours blown as well ;) Give it a try and let me know if you run into issues.
Follow this question
Once you sign in you will be able to subscribe for any updates here