GTA Style Vehicle Interaction - Project File Included

Yea I actually did try that as well but that didn’t work either. I also tried restoring the AIController it spawns with. Didn’t work either. :frowning:

PS. I’m in a MP environment and I execute vehicle enter/leave server side using a Run on Server custom event.

Oh, mine works just fine for single player, i havent fiddled with MP yet. If you have the time, can you upload the project with your MP update please so that everyone can make use of it?

Well I was working on my own implementation when I encountered the problem. While trying to fix it, someone pointed me to topic but it turned out had the same problem :stuck_out_tongue:
But as I’m working on a whole project I don’t really have something I can upload atm.
I can see if I can convert to MP though. Shouldn’t be too difficult I think and that would give us a bare bones platform for experimentation.

Oh ok, thanks. I’ll also post here if i turn into multiplayer before you do.

Actually looking at it now but the BP seems quite a bit more complex/monolithic than it could be. While I will not make it less monolithic, I may simplify/change a few nodes so it’ll be a bit easier to read/use.

And allow for entering dynamically spawned vehicles.

Status update.

I ended up moving around nodes between blueprints after all. I just couldn’t leave it all monolithic xD
That said, I currently have one bug left (aside from the infinite driving bug). Possessing the newly spawned player when you exit the vehicle doesn’t properly work yet; clients are unable to control the new character.
Also, the player orientation bug is fixed as well. I noticed that you didn’t zero out pitch and roll when you spawned the player which would cause weird behaviour such as seen in the image posted by .

EDIT: Ugh totally forgot to include the dload link for what I have so far…

Thanks for posting … judging by the vast number of vehicle questions, I’m sure will be a great help to a multitude of users!

Yeah, hope people are finding thread useful.

And thanks for the project and fixes, Omar! I’ll check it out soon.

is an awesome addition to the Car Vehicle Template! Can’t wait to see it develop. :slight_smile:

I had some time today to look at problem again and I’ve found out where the problems occur. :smiley:
Both the infinite driving and unable to control the newly created character are related to the same problem; possession desync between the server and client.

Before we exit any vehicle, we have 2 replicated characters; on the (listen) server GTA_Character_C and GTA_Character_C1, on the client GTA_Character_C2 and GTA_Character_C3.
When we exit the vehicle, a new replicated pawn for the player is created; on the server GTA_Character_C4 and on the client GTA_Character_C5. The problem is that when we posses the newly spawned character, it tries to posses GTA_Character_C4 on the client instead of the replicated GTA_Character_C5. It is as if it possesses before it replicates and ends up possessing the wrong pawn as a result.

To test , I introduced a delay node between the spawn and the possess of 1 second and after that point it works correctly; it possesses the GTA_Character_C5 pawn. delay basically allows replication to happen first.
At point, vehicles stop moving automatically (it may move along for quite a bit though if ‘Idle Brake Input == 0’ in your BP and you where driving fast) and players can properly control their characters!
I have a serious feeling that may be a bug that needs to be fixed. may possibly give people a massive headache when they’re trying to figure out why their spawning logic doesn’t work in MP even though it’s logically correct.

I’ll put the version with the Delay node added at the same link as before. I’ll update post when I uploaded it.

EDIT: File has been uploaded. You can grab it here: Dropbox - GTAVehicleSetup.7z - Simplify your life

Thanks a lot for the update, Omar. Feel free to post at AnswerHub as a bug when you are convinced that it is not expected behavior.
I will be replacing my project with yours in the first post, since yours is easier to implement and works with MP too(i’ll also upload it to my dropbox account just in case.)

Let me know if you(or anyone else) makes any additions so that i can update the links.

Thanks again.

Edit: There is an that comes with the delay. If you hit E more than once until delay is over you spawn multiple characters > posses the latest one > the rest still stays in the level. DoOnce after E that gets reset after delay should fix it though.

Yea I realized that as well when I left to do other stuff. Didn’t had the time to fix it though. I have some more time right now to dive in a bit deeper and otherwise I hope I’ll figure it out tomorrow.

EDIT: Did some more digging around and tried things with Force Net Update as well as SetPawn(…) as I noticed RestartPlayer calls explicitly before Possess is called (wrapped in a blueprint class so I could use it outside of C++ code). Sadly, nothing I tried so far has worked.
I ended up searching around the and AnswerHub to see if someone else reported anything at all and it would appear someone has the exact same: Replicating switching pawn possession - C++ - Epic Developer Community Forums
Funny enough, during my own testing I established the same thing as he did; destroying the Sedan first makes the possess work just fine…

Will continue work on tomorrow. Good night and have a Merry Christmas :wink:

Ok it turns out is a whole lot more complex than I hoped it’d be. I’m almost making a trip through half the engine to figure out what the hell is going on…
I also tried to duplicate the destroy behaviour without actually destroying it but did not result in a working solution either. I think the reason why Possess works after a Destroy is because the Destroy immediately announces the removal to all the net players.

Any UE dev around here that knows anything about problem?

EDIT: Posted on the AnswerHub: Spawning a Pawn and Possess()'ing it doesn't function properly in MP with replication - Programming & Scripting - Epic Developer Community Forums

Thanks for ; and Omar: you’re a life-saver.

Vehicle / Character possession through network is turning into a nightmare, I’m not the only one struggling with it working reliably it seems.

Glad you found it useful, ! And yeah, i’ve given up on networking for a while as it pretty much boiled my brains and i’m busy with something else right now. :\

looks really interesting. I just tried it on the 4.7 github branch (because of the added GearVR support) and it says " map is using externally referenced packages which won’t be found when in a game and all references will be broken. Performa map check for more details. Would you like to continue?"

I clicked continue and get a black screen for standalone game and UE4 freezes :frowning:

Hey haggler2,

Does it work on 4.6.1?

Hey everyone, please check the AnswerHub post here for an explanation of the networking issues going on here, 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 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 so much for the help! Glad to see the possession has been sorted, i can get back developing a project.

hi
what version work well on???