I have a quick question: is there a way to get the number of times I placed a specific actor in my level?
I’m asking because I want to create a Debugger actor that will check on BeginPlay whether it is the only instance of that actor in the level. Having more than one Debugger would start conflicting with some functionality, so I wanted to add a system that would warn me if I accidentally did such a thing so I could remove the excess of instances of the Debugger actor.
In Blueprint, there’s a node called “Get all actors of class”. It returns an array. Just read that array’s Length, that’s how many instances of that actor’s class there are in the world.
For some reason this method isn’t working. Although I’m following a tutorial and do exactly as he does but for me it doesn’t work. The variables always return 0 value. I am on 4.6 by the way
Try using the “event begin play” in the event graph.
The construction script does things before the actual actor or game mode in this case exists. That’s why self references will fail here as well.
Since the game mode is the primary BP it might just construct it before the level is loaded fully.
Event begin play well trigger as soon as the game begins. Either when the first cut scene runs out as soon as the player can do something or as soon as the actor which uses this event starts to actually exist.
He means put all those nodes after the Event Begin Play in your MyGame Event Graph instead of on the construction script, because the construction script is run before your actors are loaded in the level (even if they are manually placed).
You can check in the GameMode bp , in which use “Get all actor of class”.Do NOT use the construction script to implement this.Implement it in the Event Graph using Event Begin Play.Example .
This comment chain correctly displays the answer, but I accepted PoroKin’s reply since he shows it in working order within the first reply. Thanks, though, guys.