How can I get a reference to an actor in a level BP scene from the C++ side?

So I created the following class in C++ called TutorialLevel, and it is derived from the engine class “ALevelScriptActor”.

.h

#pragma once

#include "CoreMinimal.h"
#include "Engine/LevelScriptActor.h"
#include "TutorialLevel.generated.h"

UCLASS()
class GAMEC_API ATutorialLevel : public ALevelScriptActor
{
    GENERATED_BODY()

public:
    ATutorialLevel();

protected:
    virtual void BeginPlay() override;
};

.cpp

#include "TutorialLevel.h"
#include "Runtime/Engine/Classes/Kismet/KismetSystemLibrary.h"
#include "Engine.h"

ATutorialLevel::ATutorialLevel()
{

}

void ATutorialLevel::BeginPlay()
{
    Super::BeginPlay();

    ALevelScriptActor* currentLevel = Cast<ATutorialLevel>(()->GetLevelScriptActor());
}

I then created a BP class derived from this TutorialLevel C++ class, and I called this class TutorialLevelBP.

So, in essence, this line:

ALevelScriptActor* currentLevel = Cast<ATutorialLevel>(()->GetLevelScriptActor());

allows me to create a variable in the .cpp file to store a reference to the BP version of the level, which is what I want because the level being played in the game is actually a BP instance of the C++ class.

Here’s what I want to accomplish. You know how you can add actors to a level by dragging them into the level in the editor? Like say if I had a house actor, I could add that house to the level by dragging it from the content browser, instead of spawning it at runtime? When I worked with BP, I was able to create references to these specific actors that were already placed in the level by default, like this (https://imgur.com/a/IkTD3c4), or like this documentation (http://api.unrealengine.com/INT/Engine/Blueprints/UserGuide/Types/LevelBlueprint/index.html#referencingactors), and then from there I could get a reference back to this specific actor anywhere in the BP event graph. Now, in C++, I would like to do something similar where I get a reference to a specific actor.

You can do that directly in C++, level actor referencing is blueprint virtual machine exclusive feature. You would need to do BlueprintReadWrite variable and set that variable on level blueprint or make function with argument and pass actor reference. It still better then searching for actor in C++. Also:

ALevelScriptActor* currentLevel = Cast<ATutorialLevel>(()->GetLevelScriptActor());

Is compliantly pointless, you getting exact same object as you would use this. note that variable type only define what object variable can keep, it does does not effect what object you interact with. There no special separate object for blueprint made object, if you base object with perticial class it is that object already.

There also other options outside of level blueprint:

Asside of level blueprint, actor can be diirecly refrence by any actor on same level in property editor, so if oyu make property ASomeActor* on actor on the level, in property editor you will have list of actors of that type on level, this allows to link actors of the level.

For global non visible actors like AGameMode or APlayerController can be used also with level blueprint actor, you can create your own AWorldSettings, this allows to alter World Settings menu and also reference actors directly there too and you can get it anywhere from UWorld same as level blueprint. World Settings work in similar nature as level bluepritn, is object created with level and saved with level.