UE 4.7 project upgrade breaks UBlackboardComp

I have an AIController subclass named AEnemyAIController with the following members in the header:

UPROPERTY(Transient)
class UBlackboardComponent *BlackboardComp;
    
UPROPERTY(Transient)
class UBehaviorTreeComponent *BehaviorComp;

Both classes feature the following forward class references in the header:

class UBlackboardComponent;
class UBehaviorTreeComponent;

And the .cpp file features the following include macros, in addition to the ones for the header and other referenced custom classes:

#include "BehaviorTree/BlackboardData.h"
#include "BehaviorTree/BlackboardComponent.h"
#include "BehaviorTree/BehaviorTreeComponent.h"
#include "BehaviorTree/BehaviorTree.h"

In its implementation of Possess(), it features the following code:

AEnemyBotCharacter *Bot = Cast<AEnemyBotCharacter>(InPawn);
    
    if (Bot && Bot->BotBehavior)
    {
        UBlackboardData *BlackboardData = Bot->BotBehavior->BlackboardAsset;
        BlackboardComp->InitializeBlackboard(BlackboardData);
    }

All of the above worked as expected in UE 4.6.1, but upgrading the project to UE 4.7 with no changes to the code results in the following error:

error: non-const lvalue reference to type 'UBlackboardData' cannot bind to a value of unrelated type 'UBlackboardData *'

Either the program somehow does not know what UBlackboardData is (which would likely be due to using the wrong include macro when attempting to reference the relevant code, with the include macro being #include “BehaviorTree/BlackboardData.h”), I’m handling pointers wrong, the engine code has changed some of its pointer handling, or it’s something else entirely. What could be the cause of the same code being broken in UE 4.7 despite working perfectly and as expected in UE 4.6.1?

UBlackboardComponent::InitializeBlackboard switched over to using referenced rather than pointers, and I missed this one while supplying transition API. Sorry!

Try this:

BlackboardComp->InitializeBlackboard(*BlackboardData);

Of course you need to make sure BlackboardData != nullptr before doing that.

BTW, why do you need to do blackboard setup manually? RunBehaviorTree will set up your BB for you.

Cheers,

–mieszko

To answer your question, it’s because I used code from a tutorial that sets up the blackboard manually.

Which tutorial is that? Is that Epic’s?

IIRC it’s Epic’s.

I think you were talking about that tutorial from Chad Reddick :

So it was not an Epic tutorial.

there’s a lot of thing to change to make it work with 4.10