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:

class UItem : public UObject

    //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:

Clearly labelled “SteelShortswordActor”.

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

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:

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?


Hi , have you tried spawning that “ActorBlueprint” class via code in game and see what is spawned to check if it really is a issue of having a wrong class?

This is not “incorrect”.

“ShortswordItem_C” is instance of the object created by Blueprint’s generated class.
Class was spawned correctly.

If you spawn it again, next instance will be called “ShortswordItem_C1” and so on…

Hey, thanks for the responses.

Xavier, I’m not sure I follow - ActorBlueprint is a class member that I have assigned type “SteelShortswordActor” to - so why when loaded in C++ is it coming up as ShortswordItem? I appreciate I must be missing something obvious. I fully expect Item to be of that type, but item’s ActorBlueprint should surely be the actor i selected? Especially given that it must be a subtype of ItemActor, which ShortswordItem is not

For further info, im not sure what type to make this pointer. I just want it to represent a type that I later spawn. I’ve tried TSubclassOf AItemActor, UBlueprint, neither have worked. Any tips would be greatly appreciated

You have serialized the subclass property.
When “PostInitProperties” function is called it sets the value back to what it was serialized to.

If you don’t want it serialized then mark it Transient and set the static class yourself.