Adding a BP_Object to TArray is not valid?

Hi,

So basically, I have a:

  • TArray of ASpellSystem which acts as my spell bar. (Under mycharacter class)
  • Made a spell using BP inheriting ASpellSystem, named Fireball.
  • Adding said Fireball to my spellbar using MyCharacter BP does not work, as the fireball is not valid
  • Tested if the fireball is valid under its own BP and it seems to be valid post BeginPlay
  • Assuming that MyCharacter BP is adding the Fireball before it is initialized

Possible fixes:

  • I could maybe call postinitcomponents before adding the spell? but that wouldn’t work as I set the default class values via BP before using the spell.
  • I read around and a possible fix is to use FReferenceCollector::AddReferencedObjects but that wouldnt work considering my spells are not initialized till BeginPlay.

Here is my answerHUB with screenshots and additional details.

Adding BP_Object to TARRAY - Object added before initialization - Editor Scripting - Epic Developer Community Forums

Thank you