本文整理汇总了C++中APlayerController类的典型用法代码示例。如果您正苦于以下问题:C++ APlayerController类的具体用法?C++ APlayerController怎么用?C++ APlayerController使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了APlayerController类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: check
void UDemoNetDriver::SpawnDemoRecSpectator( UNetConnection* Connection )
{
check( Connection != NULL );
UClass* C = StaticLoadClass( AActor::StaticClass(), NULL, *DemoSpectatorClass, NULL, LOAD_None, NULL );
if ( C == NULL )
{
UE_LOG( LogDemo, Error, TEXT( "UDemoNetDriver::SpawnDemoRecSpectator: Failed to load demo spectator class." ) );
return;
}
APlayerController* Controller = World->SpawnActor<APlayerController>( C );
if ( Controller == NULL )
{
UE_LOG( LogDemo, Error, TEXT( "UDemoNetDriver::SpawnDemoRecSpectator: Failed to spawn demo spectator." ) );
return;
}
for ( FActorIterator It( World ); It; ++It)
{
if ( It->IsA( APlayerStart::StaticClass() ) )
{
Controller->SetInitialLocationAndRotation( It->GetActorLocation(), It->GetActorRotation() );
break;
}
}
Controller->SetReplicates( true );
Controller->SetAutonomousProxy( true );
Controller->SetPlayer( Connection );
}
示例2: AddIdToMuteList
void FPlayerMuteList::ServerMutePlayer(APlayerController* OwningPC, const FUniqueNetIdRepl& MuteId)
{
UWorld* World = OwningPC->GetWorld();
const TSharedPtr<const FUniqueNetId>& PlayerIdToMute = MuteId.GetUniqueNetId();
// Don't reprocess if they are already muted
AddIdToMuteList(VoiceMuteList, PlayerIdToMute);
// Add them to the packet filter list if not already on it
AddIdToMuteList(VoicePacketFilter, PlayerIdToMute);
// Replicate mute state to client
OwningPC->ClientMutePlayer(MuteId);
// Find the muted player's player controller so it can be notified
APlayerController* OtherPC = GetPlayerControllerFromNetId(World, *PlayerIdToMute);
if (OtherPC != NULL)
{
// Update their packet filter list too
OtherPC->MuteList.ClientMutePlayer(OtherPC, OwningPC->PlayerState->UniqueId);
// Tell the other PC to mute this one
OtherPC->ClientMutePlayer(OwningPC->PlayerState->UniqueId);
}
}
示例3: GetWorld
void APickUpItem::Prox_Implementation(AActor* OtherActor, UPrimitiveComponent* OtherComp, int32
OtherBodyIndex, bool bFromSweep, const FHitResult & SweepResult)
{
// if the overlapped actor is NOT the player,
// you simply should return
if (Cast<AActor>(OtherActor) == nullptr)
{
return;
}
// Get a reference to the player avatar, to give him
// the item
AAvatar *avatar = Cast<AAvatar>(UGameplayStatics::GetPlayerPawn(
GetWorld(), 0));
// Let the player pick up item
// Notice use of keyword this!
// That is how _this_ Pickup can refer to itself.
avatar->Pickup(this);
if (CoinSound != NULL)
{
UGameplayStatics::PlaySoundAtLocation(this, CoinSound, GetActorLocation());
}
// Get a reference to the controller
APlayerController* PController = GetWorld() ->GetFirstPlayerController();
// Get a reference to the HUD from the controller
AMyHUD* hud = Cast<AMyHUD>(PController->GetHUD());
hud->addMessage(Message(Icon, FString("Picked up ") + FString(" ") + Name + FString(" ")+FString::FromInt(Quantity), 2.0f, FColor::Black, FColor::Black));
Destroy();
}
示例4: int32
void APawn::PreInitializeComponents()
{
Super::PreInitializeComponents();
if (Instigator == nullptr)
{
Instigator = this;
}
if (AutoPossessPlayer != EAutoReceiveInput::Disabled && GetNetMode() != NM_Client )
{
const int32 PlayerIndex = int32(AutoPossessPlayer.GetValue()) - 1;
APlayerController* PC = UGameplayStatics::GetPlayerController(this, PlayerIndex);
if (PC)
{
PC->Possess(this);
}
else
{
GetWorld()->PersistentLevel->RegisterActorForAutoReceiveInput(this, PlayerIndex);
}
}
UpdateNavigationRelevance();
}
示例5: Tick
// Called every frame
void ACameraDirector::Tick( float DeltaTime )
{
Super::Tick( DeltaTime );
const float TimeBetweenCameraChanges = 2.0f;
const float SmoothBlendTime = 0.75f;
TimeToNextCameraChange -= DeltaTime;
if (TimeToNextCameraChange <= 0.0f)
{
TimeToNextCameraChange += TimeBetweenCameraChanges;
// Find the actor that handles control for the local player.
APlayerController* OurPlayerController = UGameplayStatics::GetPlayerController(this, 0);
if (OurPlayerController)
{
if ((OurPlayerController->GetViewTarget() != CameraOne) && (CameraOne != nullptr))
{
// Cut instantly to camera one.
OurPlayerController->SetViewTarget(CameraOne);
}
else if ((OurPlayerController->GetViewTarget() != CameraTwo) && (CameraTwo != nullptr))
{
// Blend smoothly to camera two.
OurPlayerController->SetViewTargetWithBlend(CameraTwo, SmoothBlendTime);
}
}
}
}
示例6: UE_LOG
/**
* Delegate fired when the joining process for an online session has completed
*
* @param SessionName the name of the session this callback is for
* @param bWasSuccessful true if the async action completed without error, false if there was an error
*/
void UOnlineSessionClient::OnJoinSessionComplete(FName SessionName, EOnJoinSessionCompleteResult::Type Result)
{
UE_LOG(LogOnline, Verbose, TEXT("OnJoinSessionComplete %s bSuccess: %d"), *SessionName.ToString(), static_cast<int32>(Result));
SessionInt->ClearOnJoinSessionCompleteDelegate(OnJoinSessionCompleteDelegate);
if (Result == EOnJoinSessionCompleteResult::Success)
{
FString URL;
if (SessionInt->GetResolvedConnectString(SessionName, URL))
{
APlayerController* PC = GetPlayerController();
if (PC)
{
if (bIsFromInvite)
{
URL += TEXT("?bIsFromInvite");
bIsFromInvite = false;
}
PC->ClientTravel(URL, TRAVEL_Absolute);
}
}
else
{
UE_LOG(LogOnline, Warning, TEXT("Failed to join session %s"), *SessionName.ToString());
}
}
}
示例7: PostSeamlessTravel
void AGameModeBase::PostSeamlessTravel()
{
if (GameSession)
{
GameSession->PostSeamlessTravel();
}
// We have to make a copy of the controller list, since the code after this will destroy
// and create new controllers in the world's list
TArray<TAutoWeakObjectPtr<AController> > OldControllerList;
for (auto It = GetWorld()->GetControllerIterator(); It; ++It)
{
OldControllerList.Add(*It);
}
// Handle players that are already loaded
for (FConstControllerIterator Iterator = OldControllerList.CreateConstIterator(); Iterator; ++Iterator)
{
AController* Controller = *Iterator;
if (Controller->PlayerState)
{
APlayerController* PlayerController = Cast<APlayerController>(Controller);
if (!PlayerController || PlayerController->HasClientLoadedCurrentWorld())
{
// Don't handle if player is still loading world, that gets called in ServerNotifyLoadedWorld
HandleSeamlessTravelPlayer(Controller);
}
}
}
}
示例8: NSLOCTEXT
void FPlatformerIngameMenu::ReturnToMainMenu()
{
APlatformerPlayerController * PlatformPC = (PCOwner.IsValid())? Cast<APlatformerPlayerController>(PCOwner.Get()) : NULL;
FString RemoteReturnReason = NSLOCTEXT("NetworkErrors", "HostHasLeft", "Host has left the game.").ToString();
FString LocalReturnReason(TEXT(""));
if ( PlatformPC )
{
if (PlatformPC->GetNetMode() < NM_Client)
{
for(auto Iterator = PlatformPC->GetWorld()->GetPlayerControllerIterator(); Iterator; ++Iterator)
{
APlayerController* Controller = *Iterator;
if (Controller && Controller->IsPrimaryPlayer() && Controller != PlatformPC)
{
Controller->ClientReturnToMainMenu(RemoteReturnReason);
}
}
PlatformPC->ClientReturnToMainMenu(LocalReturnReason);
}
else
{
PlatformPC->ClientReturnToMainMenu(LocalReturnReason);
}
}
DestroyRootMenu();
}
示例9: ReceivedSelectCamera
void ANetworkController::ReceivedSelectCamera(msgpack_object* Data) {
FString name = Unpack<FString>(Data);
APlayerController* PlayerController = NULL;
for (auto Iterator = GetWorld()->GetPlayerControllerIterator(); Iterator; ++Iterator) {
PlayerController = *Iterator;
break;
}
if (!PlayerController) {
return;
}
//PlayerController->PlayerCameraManager->PlayCameraAnim()
for (TActorIterator<ACameraActor> ObjIt(GetWorld()); ObjIt; ++ObjIt) {
ACameraActor* Camera = *ObjIt;
//GEngine->AddOnScreenDebugMessage(-1, 60.f, FColor::Yellow, Camera->GetName());
if (Camera->GetName() == name) {
PlayerController->SetViewTarget(Camera);
AFollowRoadCamera* FollowRoadCamera = Cast<AFollowRoadCamera>(Camera);
if (FollowRoadCamera) {
FollowRoadCamera->Start(false, 0);
}
return;
}
}
}
示例10: TickComponent
void UTDCSpectatorPawnMovement::TickComponent(float DeltaTime, enum ELevelTick TickType, FActorComponentTickFunction *ThisTickFunction)
{
Super::TickComponent(DeltaTime, TickType, ThisTickFunction);
if (!PawnOwner || !UpdatedComponent)
{
return;
}
APlayerController* PlayerController = Cast<APlayerController>(PawnOwner->GetController());
if (PlayerController && PlayerController->IsLocalController())
{
if (!bInitialLocationSet)
{
PawnOwner->SetActorRotation(PlayerController->GetControlRotation());
PawnOwner->SetActorLocation(PlayerController->GetSpawnLocation());
bInitialLocationSet = true;
}
FVector MyLocation = UpdatedComponent->GetComponentLocation();
ATDCSpectatorPawn* SpectatorPawn = Cast<ATDCSpectatorPawn>(PlayerController->GetSpectatorPawn());
if ((SpectatorPawn != NULL) && (SpectatorPawn->GetCameraComponent() != NULL))
{
SpectatorPawn->GetCameraComponent()->ClampCameraLocation(PlayerController, MyLocation);
}
UpdatedComponent->SetWorldLocation(MyLocation, false);
}
}
示例11: GetWorld
void UNetGameInstance::OnCompleted(FName SessionName, EOnJoinSessionCompleteResult::Type Result)
{
APlayerController* PC = GetWorld()->GetFirstPlayerController();
FFrame::KismetExecutionMessage(TEXT("Yeeee Join succesful"), ELogVerbosity::Warning);
auto Sessions = Online::GetSessionInterface();
if (Sessions.IsValid())
{
Sessions->ClearOnJoinSessionCompleteDelegate(Delegate);
if (Result == EOnJoinSessionCompleteResult::Success)
{
// Client travel to the server
FString ConnectString;
if (Sessions->GetResolvedConnectString(GameSessionName, ConnectString) && PC->IsValidLowLevel())
{
//UE_LOG(Network, Log, TEXT("Join session: traveling to %s"), *ConnectString);
PC->ClientTravel(ConnectString, TRAVEL_Absolute);
return;
}
}
}
}
示例12: ue_py_check
PyObject *py_ue_get_player_pawn(ue_PyUObject *self, PyObject * args)
{
ue_py_check(self);
int controller_id = 0;
if (!PyArg_ParseTuple(args, "|i:get_player_pawn", &controller_id))
{
return NULL;
}
UWorld *world = ue_get_uworld(self);
if (!world)
return PyErr_Format(PyExc_Exception, "unable to retrieve UWorld from uobject");
APlayerController *controller = UGameplayStatics::GetPlayerController(world, controller_id);
if (!controller)
return PyErr_Format(PyExc_Exception, "unable to retrieve controller %d", controller_id);
// the controller could not have a pawn
if (!controller->GetPawn())
Py_RETURN_NONE;
Py_RETURN_UOBJECT(controller->GetPawn());
}
示例13: ProcessTransition
void ACameraDirector::ProcessTransition()
{
APlayerController* PlayerController = UGameplayStatics::GetPlayerController(this, 0);
if (PlayerController)
{
FCameraStruct CameraData = ManagedCameras[CurrentCameraIndex];
AActor* Camera = CameraData.Camera;
float LinearBlend = CameraData.LinearBlend;
if (Camera)
{
if (LinearBlend > 0.f)
{
PlayerController->SetViewTargetWithBlend(Camera, LinearBlend);
}
else
{
PlayerController->SetViewTarget(Camera);
}
}
}
CurrentCameraIndex++;
CurrentCameraIndex = CurrentCameraIndex == ManagedCameras.Num() ? 0 : CurrentCameraIndex;
TimeToNextCameraChange = ManagedCameras[CurrentCameraIndex].TransitionTime;
}
示例14: Tick
// Called every frame
void ACameraDirector::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
const float TimeBetweenCameraChanges = 60.f;
const float SmoothBlendTime = 59.0f;
TimeToNextCameraChange -= DeltaTime;
if (TimeToNextCameraChange <= 0.0f)
{
TimeToNextCameraChange += TimeBetweenCameraChanges;
//Find actor that handles ctonrtol for local player.
APlayerController* OurPlayerController = UGameplayStatics::GetPlayerController(this, 0);
if (OurPlayerController)
{
if (CameraTwo && (OurPlayerController->GetViewTarget() == CameraOne))
{
//Blend smoothly to camera two.
OurPlayerController->SetViewTargetWithBlend(CameraTwo, SmoothBlendTime);
}
else if (CameraOne)
{
//Cut instantly to camera one.
//OurPlayerController->SetViewTarget(CameraOne);
OurPlayerController->SetViewTargetWithBlend(CameraOne, SmoothBlendTime);
}
}
}
}
示例15: InitSeamlessTravelPlayer
void AGameModeBase::InitSeamlessTravelPlayer(AController* NewController)
{
APlayerController* NewPC = Cast<APlayerController>(NewController);
// Find a start spot
AActor* StartSpot = FindPlayerStart(NewController);
if (StartSpot == nullptr)
{
UE_LOG(LogGameMode, Warning, TEXT("Could not find a starting spot"));
}
else
{
FRotator StartRotation(0, StartSpot->GetActorRotation().Yaw, 0);
NewController->SetInitialLocationAndRotation(StartSpot->GetActorLocation(), StartRotation);
}
NewController->StartSpot = StartSpot;
if (NewPC != nullptr)
{
NewPC->PostSeamlessTravel();
if (MustSpectate(NewPC))
{
NewPC->StartSpectatingOnly();
}
else
{
NewPC->bPlayerIsWaiting = true;
NewPC->ChangeState(NAME_Spectating);
NewPC->ClientGotoState(NAME_Spectating);
}
}
}