Get all actors in construction script

Hello,

I have save points in my game, and I usually override their behavior for testing allowing me to start from any save point by just checking a boolean in their construction script.

The problem is that if I have 2 savepoints checked only 1 will actually work obviously when I load the game.

I’ve tried using get all actors of class in the construction script but obviously it doesnt work since the objects don’t know about each other, is there something anyone would recommend so that if i Check a boolean such as Reset All Save points in the construction script it can communicate to the other ones to be turn off their boolean that would trigger the save point override…?

I made a quick video:

Get all actors of class should work, actors doesn’t need to know each other for that, only the level has to(I think)

But instead, have another class named SavePointManager that has this logic, not on the save points itself. If you have 8 savepoints and do it in the sp blueprint, you do it 64 times because each of these 8 instances attempts to do it.

it only does it on 1 BP because reset all is only checked on 1 BP and not all, and get all actors only runs when that bool is set to true… but what happens is it doesnt run on the actors, only on the calling actor setting the boolean “start from this save point” to false, so its not recognizing other actors…

I checked, and you are right. Here is the same issue with a better explanation:

Matthew J. from staff explains that construction script is run before anything, so before anything is considered to be in scene and thats why Get all actors from class doesnt work properly in construction script, however, the thread above has the explanation but no solution to your case.

I think you can do what i will explain below to workaround this, but im not sure if it will work.


Create an array of references to SavePoints in your gamemode (leave it empty)

On your savepoint blueprint, check if this savepoint is in the array from gamemode, if not, add it.

Then instead of using get all actors of class, get this array.


What i explained above has a lot of problems by itself, and it might not even work, but good luck!