Trying to build my plugin on UE 5.2 but the error cannot be referenced -- it is a deleted function is showing up

Hello,

I’m trying to build my plugin on UE 5.2, but the following error is showing up:
C++ function (declared at line xx of) cannot be referenced -- it is a deleted function

The problem is in the use of the UBlackboardComponent, I’m defining it like this:

BBComponent = CreateDefaultSubobject<UBlackboardComponent>(TEXT("BlackBoardComp"));
UBlackboardData* const bbData = BehaviorTree->BlackboardAsset;
BBComponent->InitializeBlackboard(*bbData);

Then, when I try to get a key from the UBlackboardComponent:

targetActorKey = BBComponent->GetKeyID("TargetActor");

I’m getting this error:
C++ function (declared at line xx of) cannot be referenced – it is a deleted function

I don’t know if I can share UE code, assuming it is open source, I will share the code of the FBlackboard:

// Copyright Epic Games, Inc. All Rights Reserved.

#pragma once

#include "UObject/NameTypes.h"

namespace FBlackboard
{
	const FName KeySelf = TEXT("SelfActor");

#ifdef AI_BLACKBOARD_KEY_SIZE_8
	// this is the legacy BB key size. Add AI_BLACKBOARD_KEY_SIZE_8 to your *.target.cs to enable it.
	using FKey = uint8;
	inline constexpr FKey InvalidKey = FKey(-1);
#else
	//the default BB key size is now 16
	struct FKey
	{
		constexpr FKey() = default;
		FKey(int32 InKey) {Key = IntCastChecked<uint16>(InKey); }
		constexpr FKey(uint16 InKey) : Key(InKey) {}
		constexpr FKey(uint8 InKey) = delete;
		constexpr operator int32() const { return Key; }
		constexpr operator uint16() const { return Key; }
		constexpr operator uint8() const = delete;
		constexpr bool operator==(const FKey& Other) const {return Key == Other.Key;}
		constexpr bool operator!=(const FKey& Other) const {return Key != Other.Key;}
	private:
		friend uint32 GetTypeHash(const FKey& Key);
		uint16 Key = static_cast<uint16>(-1);
	};

	inline constexpr FKey InvalidKey = FKey();

	inline uint32 GetTypeHash(const FKey& Key) { return ::GetTypeHash(Key.Key);}
#endif
}

Can anyone help me please?

Many thanks!

Anyone?

What does the error message actually say, the one you changed to “C++ function (declared at line xx of) cannot be referenced – it is a deleted function”

This is because in 5.2 constructor from uint16 to uint8 declared as deleted and your program dont know how to convert it. U have to use variable (FKey in this example) with type uint16 or uint32 and it will work

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.