I’m trying to attach a character to a vehicle in a multiplayer game. The problem is the character doesn’t always attach right for non-owner clients. Depending on the exact attachment method I use, occasionally the character is offset or totally missing when the vehicle comes into view. I suspect it’s a relevancy issue of some kind but I have no idea what since all pawns are set to always relevant, and neither the vehicle or character meshes have LODs.
I’m using the character “Hero” from the shooter game. Weapons are modified due to refactoring for vehicle weapons, but besides that I haven’t changed much, if anything.
For all clients, even the owner, I use a rep’d var “MyVehicle” for the player’s current vehicle in the PlayerState object. When it replicates I put the player’s character into the vehicle.
Each seat has a socket and I’ve tried attaching the character’s root component, the character actor itself, and just the 3p mesh by itself. All with similar results; it usually works, but occasionally doesn’t.
character vs vehicle collisions are turned off, and SetActorEnableCollision(false) is called on the character before attaching
Once it’s attached I set the character mesh to EAnimationMode::AnimationSingleNode, set the animation and play it. It’s currently using the Hero’s equip or reload anim depending on the seat.
On the server I attempt to stop movement replication with this:
charPawn->GetCharacterMovement()->DisableMovement(); charPawn->GetCharacterMovement()->bEnablePhysicsInteraction = false;
It seems like I’ve tried just about everything… any ideas?