I have an array of various effects which all inherit from a class - ProjectItemEffects
Inside it are then the actual different effects that I’m trying to spawn.
TArray<TSubclassOf<ProjectItemEffects>> ItemEffects;
It has one function inside which is just a simple:
virtual void DoStuff() override;
Now lets imagine inside the array described above it in actual live scenario there are 3 subclasses of ProjectItemEffects:
AProjIE_01 : public AProjectItemEffects
AProjIE_02 : public AProjectItemEffects
AProjIE_03 : public AProjectItemEffects
How would I go about spawning this items so that I can access the overloaded functions from those particular classes that are inherited from the base class?
If I was spawning the ‘base’ class I would do:
AProjectItemEffects* CurItemEffect = ()->SpawnActor<AProjectItemEffects>(AProjectItemEffects::StaticClass(), SpawnParams);
and then I would call:
CurItemEffect->DoStuff();
but the DoStuff() function does different things in each of the subclasses, so I need to get the reference of the class from the actual item in the array, have it spawn and have a reference to that particular spawned item with the correct TSubclassOf class cast.
I’m having issues with writing syntax correctly so it would compile, anyone who can provide some assistance, or do I have symantic / approach issue here?