void ACinemotusPlayerController::OnSwichPawn(bool increase) { //Get Current Pawn's rotation? if (PawnsInScene.Num() < 1) { return; } FString numstr = FString::Printf(TEXT("%d"), PawnsInScene.Num()); GEngine->AddOnScreenDebugMessage(-1, .5f, FColor::Yellow, numstr); int startIndex = currentPawnIndex; do { if (increase) { currentPawnIndex = currentPawnIndex + 1 < PawnsInScene.Num() ? currentPawnIndex + 1 : 0; } else { currentPawnIndex = currentPawnIndex - 1 < 0 ? PawnsInScene.Num() - 1 : currentPawnIndex - 1; } } while (PawnsInScene[currentPawnIndex]->bHidden && currentPawnIndex != startIndex); //keep going till we find a non hidden one APawn* nextPawn = PawnsInScene[currentPawnIndex]; Possess(nextPawn); SetViewTargetWithBlend(nextPawn, 0.0f); possessedCinePawn = Cast<ACinemotusDefaultPawn>(nextPawn); //GET JOYSTICK DATA GetCineData(GetPawn()); }
void AInGame_PlayerController::Respawn() { UnPossess(); AGameMode * Gamemode = GetWorld()->GetAuthGameMode(); if (Gamemode) { switch(SelectedChampionClass) { case Champion::DashSwordsman: { Gamemode->DefaultPawnClass = DashSwordsmanClass; break; } case Champion::Risputa: { Gamemode->DefaultPawnClass = RisputaClass; break; } } APawn * NewPawn = Gamemode->SpawnDefaultPawnFor(this, Gamemode->ChoosePlayerStart_Implementation(this)); Possess(NewPawn); } }
void AMurphysLawAIController::Respawn() { AMurphysLawGameMode* GameMode = Cast<AMurphysLawGameMode>(GetWorld()->GetAuthGameMode()); if (GameMode) { AMurphysLawPlayerState* MurphysLawPlayerState = Cast<AMurphysLawPlayerState>(PlayerState); MurphysLawUtils::RespawnCharacter(GameMode, MurphysLawPlayerState, MyCharacter); Possess(MyCharacter); SetBlackboardCanMove(true); } }
void ACinemotusPlayerController::SwitchToPawn(APawn* p) { int pawnIndex = GetPawnListIndex(p); if (pawnIndex == -1)//not in list { //add PawnsInScene.Add(p); } SortPawnInSceneList();//incase layer change Possess(p); SetViewTargetWithBlend(p, 0.0f); possessedCinePawn = Cast<ACinemotusDefaultPawn>(p); //GET JOYSTICK DATA GetCineData(GetPawn()); }
/* * Overriden Begin play method. Does the setup of the camera boom and third person * camera. */ void ABasePlayerController::BeginPlay() { Super::BeginPlay(); // SUPER IMPORTANT!!! Else pawn is not possessed by default (which is quite stupid btw Unreal) Possess(GetPawn()); //Check if not null, since blueprints are somethime corrupted check(CameraBoom); check(ThirdPersonCamera); CameraBoom->TargetArmLength = 300.0f; //Boom distance (distance of the camera from the player CameraBoom->bUsePawnControlRotation = true; //Use player controller rotation CameraBoom->AttachTo(GetRootComponent()); //Attach to root of player controller ThirdPersonCamera->AttachTo(CameraBoom, USpringArmComponent::SocketName); //Attach camera to camera boom ThirdPersonCamera->bUsePawnControlRotation = false; //Do not use player controller rotation }