First Game Tutorial
. Move the camera to the spectator viewpoint: C++ solution
3
protected:
UPROPERTY(EditDefaultsOnly, Category = "Gameplay")
TSubclassOf<AActor> SpectatorViewpointClass;
MyFirstGameGameMode.h
void AMyFirstGameGameMode::CompleteLevel(APawn* character,
bool succeeded)){
if (character){
MyFirstGameGameMode.cpp
character->DisableInput(nullptr);
TArray<AActor*> foundViewpoints;
UGameplayStatics::GetAllActorsOfClass(GetWorld(),
SpectatorViewpointClass, foundViewpoints);
if (foundViewpoints.Num() > 0){
APlayerController* pController = Cast<APlayerController>
(character->GetController());
if (pController)
pController->SetViewTargetWithBlend(foundViewpoints[0], 0.8f);
}
}
OnLevelCompleted(character, true);
}