Hey everyone! I’m making a simple top-down space exploration / shooter.
The issue I am facing (on a high level) is sharing a common variable between different Blueprint classes.
I’m trying to implementing a radar where, if a player has gone close enough to a point of interest, it now shows permanently on the radar.
I have a working radar on screen that spawns some widgets on the HUD that is pointing toward enemies and POIs. Currently, the only POIs are 3 spawned “Station” Actors. (done via Spawn Actor from Class > “BP_Station” on Event Begin Play in a custom “LevelSpawner” BP)
The way I am currently drawing the radar is via Get All Actors Of Class (BP_Station), then a For Each loop, where I read my “IsKnownByPlayer” variable that is set in BP_Station, when the player gets close to BP_Station.
Now into the issue: These POIs are not always going to be the station. Some POIs are going to be, for example, a black hole, or an enemy hideout, or any other possible point of interest. Point is, it’s a different Blueprint class.
To me (a not particularly logical person), the logical way to do this would be with another Blueprint Interface:
So I tried to add Another Blueprint Interface (BPI_PlayerDiscovered) with a bool variable “PlayerDiscovered”. From the BP_Station I message the interface with the bool set to true when the player gets close. Then, instead of Get All Actors of Class in my radar Widget, I use Get All Actors with Interface and target the “BPI_PlayerDiscovered”. The issue I encounter with this approach is I cannot find a way to just read that bool variable in the For Each loop located in the radar widget. I can only use the interface Event (Which “starts” the “execution chain” in the BP) or the interface Message, which seems to just set the variable to the Interface default again.
Should I watch more tutorials on how Blueprint Interfaces work? All I’d like to have is a variable on each actor with a value of False that gets set to True when the player gets close ( this is currently being done in the BP_Station with a BeginOverlap Event of a sphere component). Then using this true or false for each actor that is a specified POI, it either draws the dot on the radar or not.
My last resort would be to just cast to every single POI Blueprint, then read each’s individually made “IsKnownByPlayer” variable, but as this is intended for mobile platforms, I want to be as efficient as I can (within the constraints of Unreal )
Thank you so so much for reading through my overexplained issue, if you think you have any way to help or just any other ideas, please don’t hesitate as at this point anything at all helps. Thanks!!