I have what may be a pretty specific question. I have a character called MyCharacter. I want to create a UObject class called MyCharacterStats. MyCharacterStats will have the characters stats like health, strength and stamina and getters and setters for each stat.
So all the above is fine, now it gets a little tricky. I want to add a
UPROPERTY(EditDefaultsOnly, Category = Character)
class UMyCharacterStats* CharacterStats ;
What I want to do is create a Blueprint instantiation of MyCharacterStats. Then in the editor I can easily assign the MyCharacterStats blueprint to MyCharacter. This will make it easy to create multiple stat load out that we can swap in and out and easily change
Now the problem I am having. The blueprint of MyCharacterStats is a different type than the:
UPROPERTY(EditDefaultsOnly, Category = Character)
class UMyCharacterStats* CharacterStats ;
Which means I can’t assign the blueprint to that property in the editor. So I did the following:
class UMyCharacterStats* CharacterStats
UPROPERTY(EditDefaultsOnly, Category = Character)
TSubclassOf<class UMyCharacterStats> CharacterStatsTemplate;
This allowed me to assign the MyCharacterStats blueprint to the UPROPERTY of MyCharacter, in the editor. Now lastly I want to do this:
CharacterStats = Cast<UArenaCharacterStats>(CharacterStatsTemplate);
But when I do this CharacterStats is all NULL. It seems like things aren’t being initialized. if anyone has any experience with this or any ideas I would really appreciate the help!
Cheers!