Replicating from client to server and server to client

So i’m trying to making the client able to spawn an object and replicate it to the server and vice versa.

But i’m clueless to say the least, watching the UE4 Function Replication video didn’t make me brighter on the subject, so i went and seeked your guys guidance on this probably very tough problem.


Any help is appreciated, links to guides etcera would be awesome.

What class are those nodes in? You’ll generally want to call replicated events like that in a pawn class, since the controlling player always owns the pawn (Is the owning client). Another thing to note is that you must spawn things on the server for them to be replicated to all clients.

The nodes are on my Character Blue print, i do know that you must spawn things on the server for them to be replicated to all clients, but how would i do it vice versa and make the client spawn for example a bomb and then replicate it back to the other clients and the server.

As far as I know, that is not possible. You must call a RunOnServer event from the client, and spawn the object. Is that what was not working?

This might work.

On client – Client activating event (i.e. keypress) –> Spawn Bomb Node: Run On Server –> Explode Bomb Node: Multicast

Explode Bomb node execution path shows the bomb and the FX. Damage should be replicated on Actor.

Sounds like it would work, could you make a node showing it?

6af9e557c3f60be23b0d7bb988fd8c998f3101d9.jpeg

I’ve verified that this works in the PIE for 2 clients and a server.

This will work without Authority nodes, but they may be required for security.

I think all the FX and Damage nodes should be taken care of where I have the Comment. Your damage logic should run on the server.

I’m not sure, but if I were to attempt this then I would actually put the Explode Bomb custom event on the Bomb actor.

The thing is, the spawn bomb event and explode is in the bomb blueprint, should these events be on the character itself? I’ll provide further screenshots of my events and nodes if needed.
9542952d80b3df79f27691aadb66cbe1.png

Doesn’t the input action now call the spawn bomb on every single bomb there is on the level? As in if there are none, you won’t get any. But if there are four bombs, four additional bombs will spawn? I’d definitely handle the actual spawning of the bombs somewhere else.

What do you mean by every single bomb there is on the level? I’m completely lost on what you’re saying. And the spawning of the bombs is called on the characterbp but the spawn event is on the bomb.

Ah, nevermind. I thought that “inputaction placebomb” was in the bomb blueprint. Nevermind me then :smiley:

I went ahead and made a new project to test out rhynedahll’s solution and it worked. So now i just need to fix it for my actual game/project.

EDIT

You’re a god @Rhynedahll it works! I can’t thank you enough! :smiley:

Well, I actually pictured the concept as the player tossing the bomb. The bomb actor, say a grenade, is spawned in the world, does it’s own thing because it knows who it is – like bouncing around or rolling or whatever, then explodes and the actor is removed.

Only the player controller that does the input event to spawn the bomb should play the toss bomb animation but all the other players should see the tossing player animate and should see the bomb roll around and see it explode.