I’m trying to create a UStruct or UObject that will hold a number of TSoftObjectPtr members that will be used to load clothes, shoes, helmets, etc for a character.
Here are some attempts:
USTRUCT:
USTRUCT(BlueprintType)
struct FEquipment {
GENERATED_BODY()
UPROPERTY(BlueprintReadWrite)
TSoftObjectPtr<UMeshComponent> Mask;
};
and UObject:
UCLASS(Blueprintable, BlueprintType)
class FISTOFTHEWILD_API UCharacterEquipment : public UObject
{
GENERATED_BODY()
public:
UPROPERTY(EditAnywhere, BlueprintReadWrite)
TSoftObjectPtr<UStaticMesh> Mask;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
UStaticMesh* MaskX;
};
ACustomCharacter::ACustomCharacter(const class FObjectInitializer& ObjectInitializer) :
Super(ObjectInitializer.SetDefaultSubobjectClass<UCustomCharacterMovementComponent>(ACharacter::CharacterMovementComponentName))
{
// Set this character to call Tick() every frame. You can turn this off to improve performance if you don't need it.
PrimaryActorTick.bCanEverTick = true;
this->Equipment = NewObject<UCharacterEquipment>(this, UCharacterEquipment::StaticClass(), TEXT("equipment"));
}
class FISTOFTHEWILD_API ACustomCharacter : public ACharacter {
....
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Equipment")
UCharacterEquipment* Equipment;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Equipment")
FEquipment CharacterEquipment;
}
but I can’t set/see their values in BP defaults or in PIE:
BP class defaults:
instance of Character in PIE:
I wan’t these variables to be exposed for setting in PIE. what am I doing wrong?
is there a better way to do it?