Multiplayer Pawn Possession Issues in 4.6.1/4.7Preview [Solved]

After several days of trying to implement what should be a fairly simple feature and a few (admittedly vague) threads/hub-posts left unanswered, I’d like to highlight a few issues with Multiplayer Possession of Pawns in 4.6.1, and hopefully get the issue solved before 4.7 is released.

I’m trying to implement a very simple system that allows a Player to take control of Vehicles using their ‘Character’ pawn. In Single-Player this is incredibly simple and straightforward, but Multiplayer Pawn possession is riddled with layers of complexity that I’ve been scratching my head over for almost a week, and after trying tens of different approaches in both C++ and blueprint, following documentation and example content, I am still left with a broken system that yields different results everytime I run it. For the simplest demonstration of the issue, I recommend downloading and testing Jacky & Omar’s GTA-Style Vehicle Possession system in Multiplayer. It’s in Blueprint, but the issue is present in both C++ and BP’s. It seems I am not alone, as they too are struggling to get Pawn Possession over a network working reliably; and Omar has an Answerhub post as well that Adam Davis is currently looking into (for which I am eternally grateful!). I have since tested Omar’s project in 4.7 Preview 4, and the issue is actually made worse here, because the Delay he introduced doesn’t fix the Replication bug and as such you’re still left floating with no control over your newly spawned Character (well, cube in this case), regardless of what workaround you try.

So here’s the general flow of what is supposed to happen in my own system:

  1. Player spawns in game at the start as EITHER a vehicle or a Character class (GameMode decides). Vehicle is just a sub-class of the default ‘Pawn’ class.
  2. Characters can possess vehicles simply by walking up to them, and a Hit event on the Capsule component will talk to the server, telling the clients player controller to ‘possess’ the vehicle.
  3. The Character left behind is destroyed instantly, not before having it’s collision disabled and meshes hidden in case the destroy process takes longer than anticipated.
  4. The Player can do whatever vehicular-based activity they please and then ‘Hop Out’ of the craft.
  5. When the Client asks to exit the craft, the server spawns a new Character for them and tells the controller to possess that instead. The vehicle is then empty for other Players to come along and use.
  6. THIS is where the problem occurs, the spawned Character is possessed, but I never get control for it on the Client, and it sits hovering in the air.

There is a second issue in all of this, sometimes, my Player Controller does not successfully possess the Vehicle either, and I am once again left hanging in mid-air with no control. I experimented a little and found that if the character was destroyed before the possession completed (or rather, replicated), then it would fail completely. I got around it for now by setting the Lifespan of the character instead and hiding all it’s meshes and collisions. That seems like a lengthy and unreliable workaround for something that should just work all the time, especially over a localhost connection. In a laggy network game, that order of operations is going to cause big ol’ problems…

I have been rummaging through answerhub and the forums for a few days looking for an explanation, and even religiously followed this tutorial in 4.6.1 and tried to adapt it for this, which still didn’t work. I can’t pass ANY control information to the Character once it’s been possessed, and I float in the air in limbo, on both the server and client.

My game pivots on the ability to hop into and out of loads of different vehicles dynamically across a network, no different to UT3, GTA or similar. Unfortunately UT4 hasn’t implemented any vehicle code yet so there’s no example content to look at for this, and the fruit of my searching has been finding this post on answerhub, which demonstrates an issue with the way it’s handled by the Engine itself, not with my methods of coding, of which I’ve tried several different approaches. I feel like I’ve tried everything; spawning the vehicles dynamically at the start of the game, asking the GameMode to spawn the character and possess through there, even handling all input and possession through the player controller. Literally everything… Now I really think it’s just that there is an engine-level bug at the moment stopping clients being able to change the pawn they’re possessing reliably.

Possible Related Items:
I posted a similar thread the other day here, which highlights OnRep_Pawn not being called reliably, but again by some magical luck of the draw.

I tried to implement the system in Blueprint (again, several iterations and attempts). It’s worth noting that calling either ‘Possess’ or ‘Unpossess’ in either blueprint OR code on a client caused me an instant Access Violation crash too, with no callstack or explanation as to what the AV was. I’m betting something to do with the Pawn.

I have seen this tutorial. Unfortunately, there is no information on how to have this working over a network.

Currently my project is stalled due to this bug, I can’t go back to an earlier engine version and 4.7 makes the issue even worse. I know I know, I’m whining a bit now, but I’d really like to see this issue resolved before 4.7 hits, or I’ll end up having to wait a long old time before somebody comes across the problem and makes the fix, or even until UT4 starts adding vehicles and the dev team realises there’s a weird issue with it there.

Thanks folks!

Bump10Chars

I also have this possession bug over network too. I am trying to create an online 2 player card game system for a client. there are two static characters within the world that each connecting player controller possesses one of the free card game players. The game never connects the connecting controllers to my pawns. I also tried it in c++ just for s and g’s, but no avail.

Edit for clarity : players need to be able to possess and unpossess the player, and individual monster cards and fight with them.

I have not gotten ‘Access Violation’ but I have crashes with an unknown error with it before.

Glad to know I’m not the only one having issues then, alongside Jacky and Omar. It’s a real bummer, I can’t make any real progress on my own project now until there’s a reliable fix in place.

Omar’s Answerhub post, which has a few more details on the issue and a potential fix.

I wish there where a few more tutorials on this subject. The only one I know of is Billy Brammer’s multiplayer videos. I am still very unclear on how to get this kind of thing working.

Epic, could you make this a possible topic for one of the Thursday or Tuesday streams?

Agreed, although I think it’s genuinely not working as intended right now. None of Epic’s sample games ever need to swap pawn possession in a multiplayer game though so they wouldn’t have noticed it, their respawn methods work well enough for them as it stands (ShooterGame etc).

Even Billy’s tutorial doesn’t allow you to change pawn while playing. Jacky & Omar’s vehicle template that I showed above is the ‘closest-to-sample-content’ example I can find.

I wonder how the manta is handle in ut3 for example, if it’s a pawn that’s possessed and unpossessed or if its a specialized thingy.

edit:i googled the udk vehicle and found that vehicle is just an extended pawn. it looks like epic made it so the driver get unpossessed and vehicle gets get possessed with the drivers controller in the DriverEnter](UDK | VehiclesTechnicalGuide Classes) function.

so all is the same functionality wise. it seems, its just broken.

Yah that’s how I’ve done my vehicles as well, I destroy the character when they enter it and then try to re-spawn one when the player wants to exit. Possessing that newly spawned pawn in a server/client game just results in no control being sent to the pawn, even though I’ve possessed it most of the time, which is weird.

Issue persists in 4.7 Preview 5, though I don’t think it’s gotten any official attention yet.

Update for those following this, Adam Davis reports that they’re looking into the issue :slight_smile:

Posts are getting really spread out concerning this issue, and it makes it challenging to keep track of the important information. I’ve gathered a few here that I believe are related:

https://forums.unrealengine.com/showthread.php?57797-No-client-control-of-newly-Posessed-Pawn-amp-general-possession-issues

This is under investigation, and we prefer to address potential bug reports on the AnswerHub, so we will remain predominantly focused on there. Thanks for any help in guiding us to reproduction steps for this issue.

Cheers

So it was a bug, i really though it had to be me doing something wrong, i have been encountering so many bugs lately, makes me sad :frowning:

Hey everyone, please check the AnswerHub post here for an explanation of the networking issues going on in the GTA vehicle project, with a solution provided as well.

The most important takeaways are:

  1. Only use “Possess” on the server. We will fix future releases to make this more clear and enforce it correctly.
  2. Only spawn/destroy Pawns on the server if they can be possessed. Ideally you won’t need to destroy and spawn the Pawn in these scenarios, but it can be made to work.
  3. You guys are awesome for bearing with us and for helping with the investigation :slight_smile:

-Zak

Thanks Zak! I’ll try this out later and hopefully it’ll work for me too :slight_smile:

Just to clarify on the code side of things, does that mean we have to call ClientRestart manually from the Possess function or does that get called automatically, and we just need to insert that line and override the ClientRestart_Implementation function?

Possess() already calls ClientRestart. You just need to insert the one line into ClientRestart_Implementation where it checks for a null received Pawn (about half-way down) and call ServerCheckClientPossession() before the return. Or add a small delay between spawning and possessing, or just don’t destroy/spawn at all and reuse the initial pawn.

Ace, thanks Zak.

BTW could you add a [Solved] tag to the header of the thread? I can’t change the title for some reason, just want to make sure people can see it’s been sorted.

All set. :slight_smile:

Awesome, thx a lot for the detailed explanation Zak.

Just wanna check btw, it doesn’t seem like I can Override the ClientRestart_Implementation function in my custom Player Controller (It’s a UFunction and not virtual). Does that mean I have to go into source code and alter it there for the time being? Still a noob at this :stuck_out_tongue:

Failing that, I suppose the change will be put into the Master branch on Github sooner or later anyway…

EDIT: Been trying this now in 4.6 and it doesn’t seem to be completely fixed, but it’s closer. I’m doing things in code. Sometimes it successfully possesses, other times it doesn’t. However it doesn’t seem to be a client-side related problem, it appears that it’s now not possessing on the server 100% of the time, so it’s not getting sent to the Client. I have to do it a few times before I get a successful possession. When it does, it replicates to clients just fine.

Zak, you mentioned you were using 4.7. I’ll try upgrading my project to that and seeing if that helps the issue.

EDIT #2: Okay never mind, it DOES work, the problem is that I was hoping out of the craft, and then immediately touching it again, so it would re-possess the vehicle. Swapping Possession to quickly was causing the issue, so if I prevent that from happening, I get happy possession by the looks of it!