I’m trying to save a reference variable of an actor in my Game Manager blueprint class via the button in the screenshot below. But that button is disabled and I have no idea why. It’s disabled and when I mouse over it says “Use selected actor from the level editor” which is exactly what I’m trying to do. I selected the actor in my level and I want to save that as my default value of my variable i have selected. Both are the same exact blueprint class type.
Anyway, because I cannot do this I have to resort to saving the variable reference like this and it seems hacky. “Get all actors of class with tag”. and I have to tag them in the level editor… Seems stupid that I have to do this. I must be doing something wrong. Is it possible that this “Use selected actor from the level editor” feature does not work specifically in a Game Mode class? The thing is, I want to specifically reference this actor from the Game Mode, but maybe that’s bad practice?
I don’t think you are doing something wrong: not being able to select an Actor instance in a specific Level from a Blueprint variable default is the intended behavior for various reasons (one of which is the fact the Blueprint might be used elsewhere without the level being loaded…)
Only “Level Blueprints” might do this, as they are integral part of a Level.
So, your solution with “Get All Actors of Class with Tag” seems OK.
Though, referencing a specific actor in a level from a Blueprint default might not be the best practice: what do you expect if you have a new level than the one with the actor ? Maybe it should be designed differently, but obviously it really depends on the needs and constraints of the project
Okay so then then I have to noobishy ask. How am I supposed to get a reference to an actor in my level? Or is it expected that I dynamically create/spawn all actors through code/nodes? Because I can but that seems awkward in some cases. Because in my game I have a card game with a board and some various table top actors I’ll interact with. In my level I placed various actors on the table and I want them in those exact positions. If I dynamically spawn everything then I’ll have to program in exact locations in my set location node which seems odd when I can just place the object in the level because it’s easier…
That being said, for my deck of cards I am dynamically spawning them and initializing their position to the position of the “deck actor” on the table. That’s fine but again, the “deck actor” I had to use “get all actors of class by tag” to get a reference too which seems odd.
Sure this seems odd But that’s the only solution that really scales for larger games: with many levels (possibly even open world), online / networked, large teams working on the game, etc.
UE was designed for such constraints, and as so, things have to be done a bit differently than for a small solo indie game with one level.
So in the usual case, you are expected either to look for actors differently than a direct reference (“Get All Actors of Class with Tag” is a valid exemple, but there is other ways), or to spawn actors.
Try to study the Epic sample “Cropout” game. Even such a simple game, with only one level, is designed like this.
However, you actually can do what you want to do with “Level Blueprints”: you can reference the existing actors in the level directly (and then for example, feed that data to the Game Mode). But people realized that Level Blueprints are not scaling at all for larger projects, as they become sooner or later too complex / bloated / hard to update.