Download

Getting instances of BP classes from game directory results in Fatal Error

Hello,

I’m trying to get two instances of weapons which are Blueprint Classes and none seem to work.


void UInventory::SetupDefaultInventory()
{
	static ConstructorHelpers::FClassFinder<AWeapon> PrimaryWeapon(TEXT("Class'/Game/Blueprints/Items/Weapons/AK47.AK47_C'"));
	if (PrimaryWeapon.Class != NULL)
	{
		GEngine->AddOnScreenDebugMessage(4, 2.0f, FColor::Green, TEXT("Found a gun!"));
	}
	else
	{
		GEngine->AddOnScreenDebugMessage(4, 2.0f, FColor::Red, TEXT("Nothing found!"));
	}
	
	static ConstructorHelpers::FClassFinder<AWeapon> SecondaryWeapon(TEXT("Class'/Game/Blueprints/Items/Weapons/G36C.G36C_C'"));
	if (SecondaryWeapon.Class != NULL)
	{
		GEngine->AddOnScreenDebugMessage(5, 2.0f, FColor::Green, TEXT("Found a gun!"));
	}
	else
	{
		GEngine->AddOnScreenDebugMessage(5, 2.0f, FColor::Red, TEXT("Nothing found!"));
	}
}

Can’t even launch the project as it results in fatal error. Tried switching from Class keyword to Blueprint before the path. Nothing seems to work. Not even answerhub solutions which were accepted as an answer…