Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

How to NOT destroy pawn after logout/exit?


So what I need to do is possess a pawn (in this case a vehicle) but have it unpossess and not be destroyed when the player exits or disconnects.

That way the vehicle can be possessed by another player for example. Problem is the vehicle is destroyed before the controller so there is no easy way of doing that.

How would you go about doing this? There should be an easy way for something like this.. Any help would be greatly appreciated.

Product Version: Not Selected
more ▼

asked Apr 11 '15 at 12:29 AM in Blueprint Scripting

avatar image

166 13 16 24

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

3 answers: sort voted first

Solution found here.

Variant for changing the engine. In your C++ class, simply redefine the method by using it.

Create your Controller Class, and make it a function in the similarity:


 UFUNCTION (BlueprintNativeEvent, BlueprintCallable, Category = Miheev)
 void PawnLeavingGame ();

 UPROPERTY(EditAnywhere, BlueprintReadWrite, config, Category = Miheev)
 bool DestroyActorThenUnpossess;


 void AMController :: PawnLeavingGame_Implementation ()
 if (GetPawn ()! = NULL && DestroyActorThenUnpossess)
    GetPawn () -> Destroy ();
    SetPawn (NULL);

The redefinition source is in the code: UnrealEngine\Engine\Source\Runtime\Engine\Classes\GameFramework\PlayerController.h UnrealEngine\Engine\Source\Runtime\Engine\Private\PlayerController.cpp

And now the destruction can be regulated through the Blueprints! Yess!

alt text

I hope this will add to the standard functionality. After all, the weight of this code is only 138 bytes, and the use of space.

more ▼

answered Nov 15 '17 at 12:10 PM

avatar image

46 2 6 8

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

I found a solution for my problem... i guess its the same then yours. In my gamemode BP i want to store in the "OnLogout" several informations of the player pawn, like position, but the pawn is already destroyed in the "OnLogout" by the Unpossess'ing.

So i didnt found a way in BP honestly... my solution for it is to overwrite the UnPossess() of my custom class C_PlayerController and override the "UnPossess()" method to store stuff from the Pawn before it gets unpossessed further. In BP i then just use the value of my storeage variable "unpossessPawnTransform".

The Header part:

 class CLIENTSERVERTEST_API AC_PlayerController : public APlayerController
    /** Stores the transformation of the unpossessed pawn */
    UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=PlayerController)
    FTransform unpossessPawnTransform;
    virtual void UnPossess() override;

The CPP part:

 void AC_PlayerController::UnPossess()
    UE_LOG(LogTemp, Warning, TEXT("UnPossess()"));
    if(this->GetPawn() != NULL)
       UE_LOG(LogTemp, Warning, TEXT("UnPossess() i got some pawn"));
       this->unpossessPawnTransform = this->GetPawn()->GetActorTransform();
       UE_LOG(LogTemp, Warning, TEXT("UnPossess() dont have a pawn here too, wtf"));

On my gamemode BP it looks like this then: alt text

bpforonlogout.png (191.9 kB)
more ▼

answered Nov 05 '16 at 01:21 PM

avatar image

31 3 8

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

I'm assuming from your post that this is a multiplayer game. I'm not super solid on the multiplayer aspects of UE4, but if I understand correctly, so long as you do not destroy the vehicle on the server when you disconnect the player (on logout) the vehicle should still remain -- if it is not actively possessed by a player; however, I think the issue you're running into is that the pawn is getting removed because it is possessed by a player controller on disconnect.

To resolve this, you can try to using either the Pawn > Un Possess node in Blueprints or using the APlayerController::UnPossess() method() to separate the player controller and pawn before disconnecting the player.

Hope that helps, if not, well at least I tried. Best of Luck

more ▼

answered Jan 24 '16 at 02:54 AM

avatar image

182 9 24 25

avatar image Oxxyde Feb 19 '16 at 06:05 PM

On LogOut is too late, the pawn seems to be already unpossessed, so it gets destroyed. Do you found any solution ?

avatar image Leorekk Nov 05 '16 at 11:58 AM

Did you find a solution? I'm facing the same issue - to store the pawn transformation and other state date from it

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question