x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

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.

Product Version: Not Selected
Tags:
more ▼

asked Apr 13 '14 at 02:49 AM in Blueprint Scripting

avatar image

Thumper
966 139 149 388

avatar image Shadowriver Apr 13 '14 at 03:07 AM

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

avatar image Thumper Apr 13 '14 at 03:42 AM

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.

avatar image Thumper Apr 13 '14 at 03:46 AM

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.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

2 answers: sort voted first

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!

more ▼

answered Apr 13 '14 at 07:09 PM

avatar image

Thumper
966 139 149 388

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

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

BP Interface link

more ▼

answered Apr 13 '14 at 05:15 AM

avatar image

mikepurvis
2.5k 101 66 260

avatar image JamesG STAFF Apr 13 '14 at 08:39 AM

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

avatar image Thumper Apr 13 '14 at 01:07 PM

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.

avatar image Thumper Apr 13 '14 at 02:14 PM

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. alt text

bpinterface.jpg (151.4 kB)
avatar image mikepurvis Apr 13 '14 at 03:18 PM

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.

avatar image Thumper Apr 13 '14 at 04:45 PM

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.

avatar image Thumper Apr 13 '14 at 04:45 PM

alt text

bpinterface2.jpg (175.5 kB)
avatar image Thumper Apr 13 '14 at 04:51 PM

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

avatar image Thumper Apr 13 '14 at 05:19 PM

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?

avatar image mikepurvis Apr 13 '14 at 06:13 PM

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.

avatar image Thumper Apr 13 '14 at 06:40 PM

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.

avatar image mikepurvis Apr 13 '14 at 06:42 PM

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.

avatar image Thumper Apr 13 '14 at 06:53 PM

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.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question