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"

Setting Task_MoveTo Blackboard Key in C++

Hi all, I'm fooling around with behavior tree and blackboards in C++, and I'm attempting to keep everything in C++ and away from visual blueprints, and everything goes well except I can't seem to figure out how to set the blackboard key in the MoveTo task in C++. if I manually set it in the blueprint (please see the image), and everything else remains in C++ (creating sequence, tasks, blackboard, blackboard keys, etc.), everything works as expected.

alt text

I get this

 UStructProperty* KeyProp = FindField<UStructProperty>(UBTTask_BlackboardBase::StaticClass(), TEXT("BlackboardKey"));
             FBlackboardKeySelector* KeyPropData = KeyProp->ContainerPtrToValuePtr<FBlackboardKeySelector>(&m);

and for some reason I'm too blind to see how to set the value :D

Thanks!

Product Version: UE 4.12
Tags:
image.jpg (116.9 kB)
more ▼

asked Jul 11 '16 at 03:42 AM in C++ Programming

avatar image

fmaacmab
51 2 7 9

(comments are locked)
10|2000 characters needed characters left

3 answers: sort voted first
 OwnerComp.GetBlackboardComponent()->SetValue<UBlackboardKeyType_Object>(BlackboardKey.GetSelectedKeyID(), NewObjectValue);

this is the correct way, found it :D

more ▼

answered Jul 15 '16 at 03:46 PM

avatar image

fmaacmab
51 2 7 9

avatar image Darkhanis Jun 18 '17 at 11:10 PM

Hi, sorry to bother you. I have this same problem but I can't fit you answer in my code for some reason. I created my MoveTo task on code, now I'm trying to find a way to set the BlackboardKey in the task. Could you please put the setter you made? Thank you in advance :).

avatar image fmaacmab Jun 19 '17 at 01:21 AM

hi, thank you for your comment, I'm sorry my previous experience is not that helpful to you. As far as I remember, I figured it out by studying %path%\Epic\UE_4.xx\Engine\Source\Developer\AITestSuite\Public\BTBuilder.h (replace with your installation path and xx with your engine subversion). it may also be worth mentioning that eventually I decided to handle BT the visual way and kept C++ only for super custom situations. Hope this helps. Thanks!

(comments are locked)
10|2000 characters needed characters left

I was expecting that something simple and straightforward like this would work

 KeyPropData->SelectedKeyName = "TargetPointPosition";

but it doesn't… I mean the struct updates the value properly but there's no effect on the actual task, which still returns the field as "None"

I wonder what am I missing?...

more ▼

answered Jul 11 '16 at 07:12 PM

avatar image

fmaacmab
51 2 7 9

(comments are locked)
10|2000 characters needed characters left

Well, I extended the BTTask_MoveTo class and put a setter in it that directly updates BlackboardKeySelector's SelectedKeyName and it seems to be working okay now.

Is this approach acceptable from UE4's coding standard? Should I tackle it differently? My goal is to have the behavior tree and related items in C++ 100%, and the extended class with the setter helps accomplish this, but I would like to stick with the coding standard, please let me know your thoughts.

Thanks!

more ▼

answered Jul 12 '16 at 05:18 PM

avatar image

fmaacmab
51 2 7 9

(comments are locked)
10|2000 characters needed characters left
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