I know this post is 2 years old, but I came accross it randomly while googling about something completely unrelated, and it was the first result, so I thought I’d reply anyway in case anyone else has this issue.
This is the case where you use TSubclassOf<>; then you can drag the UObject class there, and at runtime Instantiate it with NewObject<>
ie:
class ARMYSIMUL_API AItemPickup : public AActor, public IInteractive
{
GENERATED_BODY()
public:
AItemPickup();
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Item")
TSubclassOf<UItemObject> ItemObject;
//this will return a brand new item that you can do something with.
UFUNCTION(BlueprintCallable, BlueprintPure, Category = "Item")
UItemObject* GetItem(UObject* Owner);
UItemObject* AitemPickup::GetItem(UObject* Owner)
{
//Create runtime version of my item, at spawn.
if (ItemObject != nullptr)
{
return NewObject<UItemObject>(Owner, ItemObject);
}
return nullptr;
to use it, you can just call the pickups GetItem function, passing the owner that the new item should belong to. Ie: your weapon actor, or character pawn, etc