I am setting up a multiplayer FPS game and got almost everything right except for this issue where Clients weapon does not appear where its supposed to be. In my Character Blueprint i have a function called InitializeWeapon that spawns a weapon and attaches to the player. For server everything is right but for client its still on ground. Any idea how to fix this?
InitializeWeapon function graph:
Client view (see the weapon is still at spawn location):
Just to make sure it is already asked, have you made sure that the weapon has been properly replicated? Additionally, if you go straight from A to B (meaning, directly give the second player the gun via attach actor to component without the additional steps) does the player pick up the weapon? Finally, have you made sure that your socket name and the socket name you called on your attach actor to component are the exact same?
1: Yes the weapon (which is CurrentWeapon variable) is replicated.
2: Like you said if i directly connect, this is what happens.
Problem here is character has two meshes (FPP and TPP) and weapon is being attached to FPP mesh.
3: Yes the weapon socket names are correct.
That is exactly what should have happened, so the good news is it is working as intended. What you will have to probably do is create two separate instances of the mesh and attach one to the TPP and one to the FPP. Once you do this, hide the FPP copy of the gun from other users and hide the TPP gun from the owner. What it looks like is occurring is you are currently using the same mesh for both skeletons, which causes the gun to not know which to do. If, when you pick up the gun (or begin play) you spawn the gun in both locations then just hide appropriately, you should be able to get the desired results.
Hi . Finally i fixed it!
This is how my InitializeWeapon function looks like now:
And this is how the AttachMeshes event looks like:
I’m happy to hear that you found a solution! I am marking this as answered for tracking purposes.