Download

Elevator with teleport error

I want to create elevator with TeleportTo function. Right now it works like this:


It doesn’t care about relative position or rotation. I want this to be like:
Code:




TArray<AActor*> OverlappingActors;
TeleportZone->GetOverlappingActors(OverlappingActors);
if (OverlappingActors.Num() > 0) {
    for (int i = 0; i < OverlappingActors.Num(); i++) {

      APlayerController* PC = UGameplayStatics::GetPlayerController(OverlappingActors*, 0);
      PC->DisableInput(PC);
      RelativePosition = GetActorLocation() - OverlappingActors*->GetActorLocation();
      RelativeRotation = GetActorRotation() - PC->GetControlRotation();
      FRotator NewRotation = FRotator(0.f, 0.f, 10.f);
      FQuat QuatRotation = FQuat(NewRotation);
      OverlappingActors*->TeleportTo(SecondElevator->GetActorLocation() - RelativePosition, RelativeRotation);

      PC->EnableInput(PC);
    }
}