Download

Character location not replicated after possessing another pawn

Hello everyone,

I’m having an issue where the location of my character is not being updated after I have possessed another pawn.

I have a character which can get into a vehicle. The way I implemented this, is that when the client Interacts with the vehicle, it performs a server RPC to request possession of the vehicle. The player controller then possesses the new vehicle pawn instead of the character. This possession is properly replicated back to the client.

However, I also want to move the character into the vehicle. So right after taking possession of the vehicle, I do a SetActorLocation on the character pawn (now unpossessed). This new location will fail to replicate however, and while I have control of the vehicle, the character will stay in its original location.

I can fix it by inserting a delay node in between the possession and the setting of the location. This leads me to believe these changes are being replicated in the same batch where one is taking precendence over another. Is there any way I can fix this issue?

Thanks!

Add a character skeleton to the the vehicle class. Pose it and Have it hidden when the vehicle is not possessed.

UnPossess the character → Teleport it to a preset location under the map → Possess the vehicle.

Exiting vehicle… Teleport character to vehicle → UnPossess vehicle → Hide vehicle character → Possess Character

I haven’t tried this before (even so I always wanted to try it) but perhaps you could also setup ChildActors for your Vehicle, where you put the characters in.

But I’m not exactly sure if this works, when several players can get into the vehicle at once, in terms of possession.