I’ve made a weapon blueprint and I’m trying it out but I can’t get the guns to replicate properly from the server to the client. They spawn in but they won’t attach to the character on the client side, they just hover in the air and don’t move.
Does the issue persist if you switch the Replication method on TryEquipWeapon function from Run on Server to Multicast?
Tried it, nothing changed unfortunately, it’s the exact same result as before.
Try removing the Switch Has Authority from the Equip function. At this point, you’re asking the Client to run a function, and then checking to see if it’s the Server.
Still the same result
Are you able to reproduce this in a small test project? If so, would you mind uploading it somewhere like Dropbox and giving me a download link, so I can take a look? Thanks!
Here’s the blueprints. I tried spawning the weapon with a multicast from the controller and that made the weapon move for the client but then it didn’t show for the server instead.
Unfortunately there’s not much I can test with these Blueprints outside of the project. If you’re able to zip up the project (minus the gun meshes, since those look like purchased assets), I can examine this more fully.
My guess right now is that this is because you’re attempting to do this in Blueprints that do not replicate. Neither the GameMode nor the Controller replicate, and only exist in the player’s game. Since the GameMode doesn’t have access to other players’ character BPs, and the Switch Has Authority is only allowing the Server to run the code, only the Server is getting the variable sets and function call on its character BP.
I’ve put together a test project with some standard meshes and the same blueprints.
If you have the time to look it over again I’d really appreciate it.
I solved the problem but a workaround. I rebuild the blueprints a bit in a way that made more sense, but thanks a lot for the help.
Sorry, hadn’t quite gotten to your test project yet. Can you post your workaround here for other users who might run into the same issue? Thanks!
Instead of trying to spawn and attach the blueprint to the character I made two skeletal meshes on the character which I then set with a multicast function each time I spawned a weapon for the character.