You should create a custom PowerUp class that keep all of this at the same place.
Create a new c++ class or bp that inherite from AActor and had only one of these in the persistant level, then do stuff in this BP, you’ll be able to access it from anywhere using getallActorOfCLass. If you made it in c++ you’ll be able to create a static ufunction that return the reference to it and then access it by this static function.
Never change any values from elsewhere than in this BP, or you’ll have problems later, but you can get values from anywhere. For Set values, just call a function in PowerUp like updatePlayerDead(Player).
Best way is to add events where you need, and listen for them in PowerUp that will do stuff itself…
There is a lots of way doing this but for keep your data in your case it seem maps are the variable type you need, my opinion is to make :
that is not a working code, just here for show a structure!!!
A base abstract class PowerUpDef that represent your powerUp, can be store in you pickup class:
lineartexture2D icon;
FName name;
float duration;
virtual StartBuff(Player player)
virtual StopBuff(Player player)
a struct PlayerPower that represent a powerUp durring usage:
PowerUpDef powerUpDef;
startedTime;
A map<Player,PlayerPower> aliveData that store playerPower that are alive;
then when your player pick up a powerup you can call a func
An update function that ckeck validity of timers
And
That will alow you to make different powerUpDef subclass implementing startBuff and StopBuff without doing any change to your PowerUp class.