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"

Blackboard Key Selector GetSelectedKeyID not working.

Hi,

I have a blackboard key selector however when I attempt to get the blackboard key and cast it to the correct format it fails because the Key ID is wrong. All of the other information is correct which has meant that my current solution is to use SelectedKeyName instead which achieves the same result.

I just wanted to make you aware that this was an issue. The only blackboard key selector which appears to use GetSelectedKeyID correctly is the built in BlackboardKey.

Oh this is being done in C++ by the way.

Thanks,

Product Version: UE 4.9
Tags:
more ▼

asked Mar 19 '16 at 03:50 PM in Bug Reports

avatar image

BurningArrowLtd
3 3 4 4

avatar image Doug E ♦♦ STAFF Mar 21 '16 at 03:35 PM

Hey BurningArrowLtd-

Can you provide the code that you're using or a sample project that demonstrates the issue you're having. What type are you trying to cast the blackboard key to? Can you add any debugging lines to print the value you're getting for the blackboard key before making the cast with it?

avatar image Doug E ♦♦ STAFF Mar 28 '16 at 06:07 PM

Hi BurningArrowLtd,

We have not heard back from you in a few days, so we are marking this post as Resolved for tracking purposes. If you are still experiencing the issue you reported, please respond to this message with additional information and we will offer further assistance.

Thank you.

avatar image Thomas.Edmunds May 21 '16 at 03:44 AM

Hi Doug,

I am having the same issue as the user above. I have a pretty simple behavior tree: alt text

The services are implemented in c++, and in them I've been using the FBlackboardSelector so that I can set teh blackboard key in the behavior tree in the editor. The code I used looks like this:

 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = BlackboardKeys)
 struct FBlackboardKeySelector TargetPosition_Key;

Like the previous poster, I found that when I used GetSelectedKeyID() to access the blackboard value in c++ I would get a debug value back, because the ID that is being returns is 255. I got around this by using the Key name instead:

 OwnerComp.GetBlackboardComponent()->SetValueAsVector(TargetPosition_Key.SelectedKeyName, GoalLocation);

That line works as expected and sets the value as expected. The name also works for getting the value from the blackboard.

My problem comes from the BTTask_MoveTo task. It uses the ID like so:

 const FVector TargetLocation = MyBlackboard->GetValue<UBlackboardKeyType_Vector>(BlackboardKey.GetSelectedKeyID());

I assume the ID must be failing here as well because it returns a vector with all max values, which is debug value.

I can see that the blackboard variable is being updated correctly from my code using the key name, but the id seems to be failing in all cases. This is not just for the GoalLocation vector variable either, it seems to be all of the keys, including vectors, objects and floats.

I have no idea what the issue is, so any help is appreciated.

Thanks,

Thomas

avatar image Doug E ♦♦ STAFF May 23 '16 at 02:04 PM

Hey Thomas-

I've attempted to setup a project but have not had success reproducing this on my own. If you're able to reproduce this in a new project, can you attach a copy of the project to help provide additional information for reporting this issue?

avatar image Thomas.Edmunds May 27 '16 at 09:03 PM

Project File

Hi Doug,

I was able to reproduce the issue in this bare-bones project. The only weird thing I can think of is that it is in UE version 4.9. The issue is the exact same as in my other project, where the id is returning 255.

In this project, it should just print out the blackboard key it is getting and it's id (which is incorrect) and the value (which is correct because it's accessed via the key name)

Thanks

avatar image Doug E ♦♦ STAFF May 31 '16 at 03:06 PM

Hey Thomas-

The .zip file only included a Config, Content, and Source folder. It did not have the .uporject file to open the actual project. Can you try zipping the entire project folder (minus Saved & Intermediate folders) and upload again please?

avatar image Doug E ♦♦ STAFF Jun 07 '16 at 05:11 PM

Hi Thomas,

We have not heard back from you in a few days, so we are marking this post as Resolved for tracking purposes. If you are still experiencing the issue you reported, please respond to this message with additional information and we will offer further assistance.

Thank you.

avatar image Thomas.Edmunds Jun 09 '16 at 03:01 AM

Hi Doug,

Sorry for the delay, I kind of moved on with a hack. Can't believe I forgot the project file, hopefully this one has everything.link text

After testing that you can build and open that project, it looks like I you just need to drop a B_TestAICharacter in the level to see the printout I was referring to.

avatar image Doug E ♦♦ STAFF Jun 09 '16 at 03:14 PM

Hey Thomas,

When I open the project and add the B_TestAI Character to the level, I see "key name = TestVector, id = 255, value = (-50 , 180 , 138)" printed to the screen. Can you confirm this is what you're seeing as well as what you expect to see? Additionally, the project you sent does not compile for me in engine versions past 4.9. Can you let me know if you get the same problem in more current engines by opening a copy of the project in 4.12?

avatar image Thomas.Edmunds Jun 12 '16 at 03:29 AM

Yes that is the output I expected; the problem is the id=255 part since that is the debug id value. I do not have a newer version of the engine downloaded so unfortunately I cannot test it right now, but it would not surprise me if this is only an issue with this older version.

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

2 answers: sort voted first

Hey,

Hoping I'm not too late ^^

I ran in the exactly same problem, and after looking into Unreal sources, I found the correct way to add a new blackboard key selector. You have to initialize your blackboard key selector in your cpp like this:

 void UMETA_Decorator_IsInRange::InitializeFromAsset(UBehaviorTree& Asset)
 {
     Super::InitializeFromAsset(Asset);
 
     UBlackboardData* BBAsset = GetBlackboardAsset();
     if (ensure(BBAsset))
     {
         m_RangeBlackboardKey.ResolveSelectedKey(*BBAsset);
         m_SelfLocationBlackboardKey.ResolveSelectedKey(*BBAsset);
     }
 }



more ▼

answered Jul 01 '16 at 01:00 PM

avatar image

KevinDrure
100 9 12 19

avatar image CodeSpartan Jun 19 '17 at 01:26 AM

This is the correct answer. Thank you.

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

Hey Thomas-

There have been multiple fixes applied to AI since 4.9, and it is likely that this has been resolved in a newer engine version. If you're able to reproduce this in the latest engine (4.12.3) we can investigate further, please provide the setup steps to recreate the issue. For now I will be marking this post as resolved until more information is available.

Cheers

Doug Wilson

more ▼

answered Jun 16 '16 at 06:14 PM

(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