Assigning a blueprint? Cannot convert from 'UClass *'

Hi, I’m following an older tutorial and have managed to adapt most of the deprecated code so far, but I am unsure of how to fix this particular issue.

In my constructor:


    static ConstructorHelpers::FObjectFinder<UBlueprint> WeaponBlueprint(TEXT("Blueprint'/Game/Equipment/Blueprints/BaseWeaponBP.BaseWeaponBP'"));
    WeaponSpawn = NULL;

    if (WeaponBlueprint.Succeeded())
    {
        WeaponSpawn = (UClass*)WeaponBlueprint.Object->GeneratedClass;
    }

in my header:


    UPROPERTY(VisibleAnywhere, Category = Spawn)
        class ATribesmenWeapon* WeaponSpawn;

My weapon class is #included in my header.

This line in particular gives me the following error:


WeaponSpawn = (UClass*)WeaponBlueprint.Object->GeneratedClass;

"a value of type “UClass” cannot be assigned to an entity of type “ATribesmenWeapon *”

I suspect there is just a new syntax, but I haven’t assigned blueprints in C++ before, so I’m not quite sure of what it should look like.

Edit: I managed to work around the error by changing it to:


UClass* WeaponSpawn = (UClass*)WeaponBlueprint.Object->GeneratedClass;

However, that means actually spawning it won’t work, as my spawner isn’t expecting a UClass, but is rather a pointer. So I suspect converting the previous line to UClass wasn’t the right move after all?


ATribesmenWeapon* Spawner = GetWorld()->SpawnActor<ATribesmenWeapon>(WeaponSpawn, GetActorLocation(), GetActorRotation(), SpawnParams);