How do I get a possessed pawn to show client actions to all other players?

I’m trying to make a multiplayer prototype for a friend, but client activity always gets me.

I have a stationary gun pawn that is a static mesh. Both the listen server player and a client can possess this stationary pawn. Server player replication is fine because of a built-in setting. The client side is my problem.

The client can possess the gun and rotate it in the client view, but that’s it. The client can’t fire the gun, and nothing shows on the server player or on other clients. It just looks like the client is standing next to the gun and not doing anything.

I’ve watched tutorials, I’ve searched through the forums, and I’ve read through the massive powerpoint all about replication from the UE4 guy who wrote the system.

I’ve tackled this problem 10 different ways over 3 days. I’m clearly missing something obvious that I don’t understand.

Below is an image in the pawn of my current Blueprint setup to rotate the stationary gun. The client locally sees the gun rotate, but nobody else does. I know I’m a scrub for using Blueprints, but I need whatever help I can get. What simplistic thing am I not understanding and/or missing? I will provide any other needed information when I can, but it’s 1 AM for me now and I have 12 hours of work tomorrow.

You are using the server rotation on the server side.
Instead you have to transfer the clients rotation to the server and use this in your share rotation method.

Variable Replication is always only done from server to clients.

So from my understanding, which obviously isn’t great, I need to set the rotation on the client and then send that rotation to the server with “Run on Server” selected for the function. Then have the server tell all other clients to rotate the object as well via a multicast function. Please let me know if I’m wrong.

I tried the following below from my best attempt at following your advice(sorry for function name changes). The listen server can now see when the client rotates the gun, kind of. The rotation the listen server player is viewing seems to be getting reset to it’s default rotation at the same time the client is trying to rotate it, causing a stuttering effect.

Almost. You should use a replicated variable instead of the multicast.

Multicasts are only used for things to happen one time. If you use a replicated variable with an OnRep function the function is always called when a client gets the replicated value.

But there are some other things to consider, for example that you normally need an algorithm to smooth out the animations between the replicated values and so on.

For example:
I wouldn’t turn the scene component directly but a rotation variable instead and then use linear interpolation to move the actual Scene component. The turning rotation would then be my replicated value. In the OnRep method I would then also use the lerp to animate the object.

You should also consider reading the replication documentation and do some tutorials about it

Yeah I’m not gonna lie. This is my first multiplayer attempt in over a year and I completely forgot variables could even be replicated. I think I’m going to go back to the basics before finishing this. Clearly I need a refresher. Thank you for trying to help an idiot.

No problem.

Not knowing such things is not being an idiot.
These things are complex and there are many of these. Don’t become frustrated and keep having fun with the engine and everything is fine. :slight_smile: