When you say “level instance actor”, do you just mean an actor in the level instance or do you mean the actual level instance actor itself? When a Level Instance is loaded, there is a placeholder actor that is of type ALevelInstance. It’s an actor that takes the place of the level instance during initialization. But I suspect this isn’t what you’re talking about. From your phrasing, it seems like you just want an actor in your Level Instance that handles setup. Could you clarify which one you are using?
What type is the manager? You said it’s a blueprint. What kind of blueprint? What’s the base class? You said GetParent() returns null for the actor. Does that mean the blueprint was an actor or the return value was supposed to be an actor? Trying to understand the hierarchy.
If you’re trying to get a parent, I don’t understand how a BP would have one if it’s an actor. If you’re in a blueprint of an actor, SELF is the actor, not GetParent(). So you can just use manager->GetComponent() directly.
I played around a bit with Level Instances. Here’s something that may work. Suppose you add a few Level Instances into your level. In each Level Instance in the Outliner, go to the Actor subsection and add a unique tag. Make sure it’s in the Actor section, not the component one. Add something like Elevator1. In the other one, add Elevator2 tag. I think the Level Instances need to be Standalone.
Place a dummy actor in the main scene (not in the level instance). In its blueprint BeginPlay event, do a GetAllActorsOfClass with a class of LevelInstance. Then do a ForEach on the output. Grab the Tags. Check that it’s not empty and that the first entry starts with “Elevator”. If so, grab the index from the tag.
At this point, you’ll need some C++ since this function isn’t available in blueprints. You can put this as a static function in your custom GameInstance if it’s single player.
Then you can do something like this (static function):
AActor* MyGameInstance::GetSubLevelActor(ALevelInstance *LevelInstance, const FName &Tag)
{
UWorld* world = this->GetWorld();
ULevelInstanceSubsystem* LevelInstanceSubsystem =
UWorld::GetSubsystem<ULevelInstanceSubsystem>(world);
if (LevelInstanceSubsystem)
{
AActor *LocalActor = nullptr;
LevelInstanceSubsystem->ForEachActorInLevelInstance(LevelInstance, [&LocalActor](AActor* Actor)
{
// Ignore World Settings.
if (Actor->IsA<AWorldSettings>())
return true;
if (Actor->AghocHasTag(Tag))
{
LocalActor = Actor;
return false;
}
return true;
});
return LocalActor;
}
The tag you pass in is a tag for an actor inside your LevelInstance where you want to set an ID or something.
So in your blueprint, you call this function with your LevelInstance from above. And the Tag would be something like “ElevatorActor”. Make sure this tag exists on the actor (inside your level instance) where you want to store the ID.
So with the returned Actor, you would set the ID on it. You will have to cast or use an interface. If you cast, make sure the little eyeball is on next to your ID variable.
Now that the ID is set, your blueprints in your Level Instance can go different height or do different things based on this ID.
A bit of warning though. Don’t put lighting or navigation in any Level Instances or Streaming Level.