10{
11 if (InWorld == nullptr)
12 {
13 return;
14 }
15
16 APlayerController* PC = InWorld->GetFirstPlayerController();
17
18 if (PC == nullptr)
19 {
20 return;
21 }
22
23 APawn* Pawn = PC->GetPawn();
24
25 if (Pawn == nullptr)
26 {
27 return;
28 }
29
30 TArray<AActor*> PlayerStarts;
31
32 UGameplayStatics::GetAllActorsOfClass(InWorld, APlayerStart::StaticClass(), PlayerStarts);
33
34 if (PlayerStarts.IsEmpty())
35 {
36 return;
37 }
38
39 const AActor* StartActor = PlayerStarts[0];
40 const FVector Location = StartActor->GetActorLocation();
41 const FRotator Rotation = StartActor->GetActorRotation();
42
43 Pawn->SetActorLocationAndRotation(Location, Rotation, false, nullptr, ETeleportType::TeleportPhysics);
44}