Download

There is no way of keeping a vehicle after exit

Hello,

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 in MP for example.
Problem is the vehicle is destroyed before the controller so there is no easy way of doing that with BP.

There should be an easy way for something like this… it’s a pretty common thing to do :stuck_out_tongue:

not sure if you have seen these threads which might help you

also from epic
https://docs.unrealengine.com/latest/INT/Gameplay/HowTo/PossessPawns/Blueprints/index.html

As a connoisseur of Pawn Possession problems previously, I can tell you that Possession has been fixed in Multi-player in 4.8 thanks to Zak Middleton :slight_smile:

The threads that Geodav linked to contain temporary work-arounds for the meantime though, I’m just gonna wait for the 4.8 Pre-release and keep busy with something else in the meantime.

Hey thanks for replying Guys :slight_smile:

It sounds like you didn’t understand my problem though!.. I have no issues with possessing/unpossessing in multiplayer! the problem comes when a player exits the game WHILE possessing the vehicle… which causes the vehicle to despawn… it’s the hard-coded behavior unfortunately.

I do not see anyone talk about this problem in any of those links(?) :stuck_out_tongue: I hope I didn’t miss it somehow lol (if I did then my apologies… just point me to the right direction)

EDIT: Found the responsible code, here in APlayerController.cpp

Essentially, you can add your own code here, checking/casting the pawn against the types you’ve created, then choose whether to call destroy or not :). It’s a virtual function, so you can override it in your own PlayerController class.



void APlayerController::PawnLeavingGame()
{
	if (GetPawn() != NULL)
	{
		GetPawn()->Destroy();
		SetPawn(NULL);
	}
}


Oh! I was searching for that for like an hour… I looked, pawn, character, actor… I must have missed it :stuck_out_tongue:

Thanks for that TheJamsh! I should be able to make a custom controller now.

Although I still hope Epic exposes that functionality in BP… it’s pretty basic. :stuck_out_tongue: