// Fill out your copyright notice in the Description page of Project Settings. #include "LyraSpectatorPawn.h" #include "Editor.h" #include "EngineUtils.h" #include "LevelEditorSubsystem.h" #include "Character/LyraCharacter.h" #include "Character/LyraPawn.h" // Sets default values ALyraSpectatorPawn::ALyraSpectatorPawn() { // Set this pawn to call Tick() every frame. You can turn this off to improve performance if you don't need it. PrimaryActorTick.bCanEverTick = true; } void ALyraSpectatorPawn::BeginPlay() { Super::BeginPlay(); ULevelEditorSubsystem* LevelEditorSubsystem = GEditor->GetEditorSubsystem(); LevelEditorSubsystem->EjectPilotLevelActor(); } // Called every frame void ALyraSpectatorPawn::Tick(float DeltaTime) { Super::Tick(DeltaTime); ULevelEditorSubsystem* LevelEditorSubsystem = GEditor->GetEditorSubsystem(); AActor* ActorToPilot = LevelEditorSubsystem->GetPilotLevelActor(); if (Cast(ActorToPilot)) return; for (ALyraCharacter* Character : TActorRange(GetWorld())) { ActorToPilot = Character; break; } if (!IsValid(ActorToPilot)) return; LevelEditorSubsystem->PilotLevelActor(ActorToPilot); }