I’m building a turn based combat game where the characters use cards to attack.
For the cards I have a BP_CardBase that is a child of a UObject and holds all the parameters a single card can have. Then each card is a child class of BP_CardBase and holds the specific values of that card, e.g. damage and modifiers.
A character in combat has an array of soft class references to each card they are holding. The system then reads the values from the class defaults.
When I open the project, go to my combat map and start the game it seems to be unable to read those class defaults, however it does read how many elements are in the array. Funnily enough once I open all the card blueprints they are displayed just fine. This also works on an individual basis, if I just open the blueprint of one card only this one is shown in the menu.
There is a video attached to show that flow.
If I think further ahead to when I have hundreds of cards I just can’t open all of them on every project start, so something else must be wrong. I’d appreciate all pointers. I have also just updated to 5.4.4 and I can’t be sure if this has or hasn’t happened before.
Not sure what your setup looks like, but soft pointers of any type need to be loaded first. Opening the blueprint in the editor (among other editor actions) load the blueprints, which is why it works after that
Also for your case, if there is no stateful data in your cards, a data asset makes more sense
You can make a new blueprint deriving from PrimaryDataAsset and then make your cards DataAssets of that type instead (miscellaneous → Data Asset)
If the cards are actually instantiated at runtime, by creating new objects, then it’s probably easier to read the data from the instances
Not sure what the packaging error is, if you can post the packaging error message we might be able to help
thanks a lot for the replies. I have managed to solve the issue in the meantime and it was exatly as said here. The card array is a variable on the unit that owns it, so when the unit is spawned I load all the card classess that are in their hand array on the EventBeginPlay. Easy thing to overlook if you haven’t done this before.