how to pass variables between Ai controllers.

Currently I have one AI controller that moves around a character class through behavior tree. I have another character class that also moves around through behavior tree. I want to share the variable on one with the other.

There many ways how you could do that, answer depends on how you want them to interact and what those variables suppose to do.

I want to pass a vector from one to the other. I want to pass the location of class that is moving to the other. Normal ways do not appear to work. In my bahavior tree I have one Task that is moving this AI around. In that task from the event tick, I cast to the AI controller, and then use pawn controllers location to do a simple move. Now the other AI Class that I want to recieve this information, I want to be able to feed it the location generated. I’ve tried creating an object variable of that class, but it just reads out 0,0,0 as though it’s not getting any value.

I’ve also tried updating a black board key but it doesn’t translate on the other side. Each class has it’s own Behavior Tree, but the BT’s both reference the same Black Board with a vector Key. I tried creating a service on one that would set this vector black board key, and on the other I get it and it’s 0,0,0 out. I print to screen on both ends. It reads the good location on the one that sets the black board key, but the other it’s all 0,0,0. The key is "editable on both sides so I don’t see how it won’t pass through.

Make a Blueprint Interface, and pass the variable that way.

BP Interface link

You don’t need an interface to communicate, you can just cast and access directly if you know what type it is!

I’ve tried casting with no luck. From which bp would you think to do so from? I’ve tried it from services, decorators, tasks, ai controller and they all fail. These characters are spawned not placed. It seems like one is not allow to cast to the other. An example would really be helpful as this point.

Just have a vector for the Input if that is what you want, why do all that casting in there?

The last picture looks right, the middle one is confused. That would be the one to receive the location as well so should be setting the location. The return value could just be a bool, true if it was set, or false if it wasn’t.

I think what you are missing is that this function is the one called. Where you want to call it from and have the object cast correctly, you will see the Interface function in it’s context menu. It will start with Call. Such as Call Pass Pride Core.

Okay so the interface seems like a good way because the two types are not of parent child relationship, they are different types. So this is where I’m at. First time setting up a BP interface and I’m not convinced I’m linking this together right.

Okay So I’ve tried that and still getting 0,0,0’s from it. I added the print’s to see if the function is firing and it’s not. So the 0,0,0s make sense but still I’m not able to pass this variable over.

Also, looking over this tutorial on BP interfaces. [link text][1]

Blockquote When an Interface is added to a Blueprint, that Blueprint must implement the Interface’s functions in order to have them perform any action when called. This is done by placing Event nodes for the Interface functions in the EventGraph. The nodes connected to the Event define the functionality, or implementation, for the function.
Blockquote

It sounds like I’m supposed to use an event to fire the functions? Which confuses me, because the function only has an output execution wire, so where would I stick this event to fire these?
[1]: https://docs.unrealengine.com/latest/INT/Engine/Blueprints/UserGuide/Types/Interface/UsingInterfaces/index.html

I think the problem here is that I’m not getting a successful reference to the object “prowl”. When you call the function in local version it prints out the vector just fine, but calling the function version under “interfaces messages” - the intended version, does not. I think it’s because that version requires an object reference to that BP. Just creating an object ref variable and using that fails to establish a reference. If this object already existed in the world and was not being spawned at run, I could just reference the BP in the details panel to accomadate my object variable, but I can’t do that. So how does one acheive a reference if the object doesn’t exist yet?

That BP looks more complicated than it needs to be. You can’t get a reference to an object before it’s spawned. You can search through the Actors, to get the one you want.

If that is in a BT Task, a Service should set the BlackBoard Object, and you should only be in that Task if a Condition Decorator confirmed that the Object was set.

You can compare against null, and continue if not equal.

They are spawned at run. So they are spawned by the time this BP is running because these are Behavior Tree Tasks. It’s only complicated by a few print’s so that I can see where the signal is getting to. It’s not getting into those functions that’s why that stuff is there.

It’s two Behavior Tree. There is one on Pride, and one on Prowl, They are two different character classes. Each with their own BT. They do share the same BB, but I can’t get a BB value to cross between the classes/ BT’s, Normally I would do that, I would create a key in the BB, set it in a service, check it in the decorator, and it could be passed between. It’s not working that way. I need an interface, normal means of casting do not work. There is an example in the content examples, but it’s very difficult to decipher. Try Spawning two unique character classes, Just have em drop to the ground at run time. Then try to pass a value between them. Make sure one is using one AI controller and the other is using a different one.

It looks like the problem I was having is that when I was handing the reference BP target to my interface function I was handing only one, when in fact I should have handed it an array of them. I’m spawning 5 of these characters so for now I’m using the “Get All Actors of Class” function and feeding that into the target slot of my interface function. Now it fires the function correctly and I can see the information updated. Bahg!