I have a question related to Unreal Engine. I have two types of pawn possess from…
- User
I have a question related to Unreal Engine. I have two types of pawn possess from interactive object and trigger. Trigger overlapEvent is called only on server whereas interactive object calls possess form client to server. So i created two functions one which handle possess logic from client and from server. I though about eveything but now i need to use prePossess logic on server and i start to think that tere is better impementation of this. And please don't change interaction system. void ASV_BasePlayerController::PossessFromClient(APawn* InPawn) { if(!IsValid(InPawn)) return;
ActionOnPrePossessLocally(); FTimerHandle ServerPossessTimerHandle; FTimerDelegate ServerPossessDelegate = FTimerDelegate::CreateUObject(this, &ASV_BasePlayerController::ServerPossess, InPawn);
//Производим поссесс когда экран полностью стал черным GetWorldTimerManager().SetTimer(ServerPossessTimerHandle, ServerPossessDelegate, PossessTime, false); }
void ASV_BasePlayerController::PossessFromServer(APawn* InPawn) { if (!IsValid(InPawn)) return; ClientActionOnPrePossess();
FTimerHandle ServerPossessTimerHandle; FTimerDelegate ServerPossessDelegate = FTimerDelegate::CreateUObject(this, &ASV_BasePlayerController::Possess, InPawn);
//Производим поссесс когда экран полностью стал черным GetWorldTimerManager().SetTimer(ServerPossessTimerHandle, ServerPossessDelegate, PossessTime, false); }
void ASV_BasePlayerController::ClientActionOnPrePossess_Implementation() { ActionOnPrePossessLocally(); }
void ASV_BasePlayerController::ActionOnPrePossessLocally() { SetInputMode(FInputModeUIOnly());
PlayerCameraManager->StartCameraFade(0.f, 1.f, PossessTime, FColor::Black, true, true);
if (auto character = StaticCast<ASV_BaseCharacter*>(GetPawn())) { character->PrePossessClient(); } }
void ASV_BasePlayerController::OnPossess(APawn* InPawn) { Super::OnPossess(InPawn); ClientActionOnPossess(InPawn); }
void ASV_BasePlayerController::ClientActionOnPossess_Implementation(APawn* InPawn) { SetInputMode(FInputModeGameOnly());
if(InPawn) { SetControlRotation(InPawn->GetActorRotation()); }
PlayerCameraManager->StartCameraFade(1.f, 0.f, 2.f, FColor::Black, true, true); }
void ASV_BasePlayerController::ServerPossess_Implementation(APawn* inPawn) { Possess(inPawn); } Also i wanted to say that from interactive object i can't get interacting pawn/controller (so i start possessing from client because i can use getPlayerController with 0 index) whereas i can get pawn from trigger object because it is function parameter.
- Assistant