Blueprint derived from custom C++ class has incorrect members when loaded

Hi Guys,

I have a custom class, UItem, derived from UObject. It contains a lot of information about a given in-game item, including a reference to an actor blueprint, in case we drop it from an inventory/equip it and want to show the appearance, for example.

Here’s a quick look at the header with all of the extra stuff taken out:

UCLASS(Blueprintable)
class UItem : public UObject
{
    GENERATED_UCLASS_BODY()

    //The blueprint of the actor
    UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Item")
    TSubclassOf<AItemActor> ActorBlueprint;
}

AItemActor is derived from AActor.

In editor, I have created a blueprint derived from UItem - called ShortswordItem. It sets a bunch of variables - including the “ActorBlueprint” variable, which is set to another blueprint, itself derived from AItemActor. Here’s how it looks:

https://forums.unrealengine.com/filedata/fetch?id=1472250&d=1525692801

Clearly labelled “SteelShortswordActor”.

I then load this UItem-derived object in C++. This is how it looks while debugging:

https://forums.unrealengine.com/filedata/fetch?id=1472251&d=1525692905

This is correct. However, the ActorBlueprint variable is inexplicably also set to the same value, despite the image before showing it set to the actor:

https://forums.unrealengine.com/filedata/fetch?id=1472252&d=1525692942

The ActorBlueprint should be the “SteelShortswordActor” blueprint.

Have I made a mistake somewhere? Is this a bug? Is there a better approach for this sort of thing?

Thanks!

That’s how unreal handles it. It should have no real effect on operations.

Hi Harry,

Sorry, I might have miscommunicated. When I load item, I actually want to spawn an actor using the type specified by the member ActorBlueprint. I can’t spawn ShortswordItem as it isn’t an actor, it should be the type I selected in the editor, SteelShortswordActor. Any ideas on why it’s coming up as a different type?