# Client to client replication???

**URL:** <https://forums.unrealengine.com/t/client-to-client-replication/1776529>\
**Category:** Programming & Scripting\
**Tags:** client-replication, unreal-engine, Multiplayer, question, Blueprint\
**Created:** [March 28, 2024, 7:54pm UTC](https://forums.unrealengine.com/t/client-to-client-replication/1776529 "2024-03-28T19:54:14Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![ruigol](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/ruigol/32/964789_2.png) [@ruigol](https://forums.unrealengine.com/u/ruigol)\
**Post date:** [March 28, 2024, 7:54pm UTC](https://forums.unrealengine.com/t/client-to-client-replication/1776529/1 "2024-03-28T19:54:14Z")

</div>

First off, I know clients can’t communicate to each other, they have to go via the server. But I’m having trouble making it work. For most things I can do it with a RPC, custom event\>run on server\>multicast… but it isn’t working in the case.

I am trying to (as client 1) tell client 2 to teleport and have client 1, 2 & the host see it happen.

I have a horizontal box here:

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/0/d/20d6d5d8b995aef44b1ea41043aacbab3176fca7.png)  
It gets populated with these buttons, and the information to identify each player  
 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/3/b/d/3bd6ecf1e004f2e56a9dfac987568d1fd391e1bf.png)  
The spawned button has this logic to pass along the correct player identifying integer  
 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/3/f/a/3fac19d714c9ce74bea6061843b921de18e7e9df.png)  
So after clicking which player I want to affect and thus setting ‘affected player int’ I then click what I want to happen, in this case for that affected player to teleport  
 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/4/3/d/43dfa1bbf1c1063ac8cf314eeb04ea44623b2eb4.png)  
Now in the player character i have a custom event triggering an event run on the server  
 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/8/4/4/84415eba969e4cea290154dd8d3bc0b18d7285cc.png)  
…get your glasses on for this…  
the server event triggers a multipcast event which tells the affected player to teleport  
 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/e/1/7/e17d6d06a2ee911452b1d70025385940b18c5e85.png)

It works perfectly when the host does it, but not when the client does it. I’ve tried every method of trial and error involving switch has authority and tons of other code to get to this point, im pretty sure now its just a matter of overcoming the client to client via server thing, which i thought i was doing with the RPC… but apparently not.

---

<div class="post-metadata">

**Author:** ![GarnerP57](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@GarnerP57](https://forums.unrealengine.com/u/GarnerP57)\
**Post date:** [March 28, 2024, 8:36pm UTC](https://forums.unrealengine.com/t/client-to-client-replication/1776529/2 "2024-03-28T20:36:24Z")

</div>

Teleporting should only be done by the server there is no need to Multicast.

You are most likely trying to make a RunOnServer RPC from a Character you don’t own and the RPC is dropped.

Generally Multicast RPC should only be used for temporary visual or sound effects. Use replicated variables for lasting changes.

---

<div class="post-metadata">

**Author:** ![ruigol](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/ruigol/32/964789_2.png) [@ruigol](https://forums.unrealengine.com/u/ruigol)\
**Post date:** [March 28, 2024, 8:40pm UTC](https://forums.unrealengine.com/t/client-to-client-replication/1776529/3 "2024-03-28T20:40:47Z")

</div>

Yeah, I know normally it should only be done on server, but im building some dev tools for debugging and I want to be able to do it as a client on another client, is it possible?

---

<div class="post-metadata">

**Author:** ![GarnerP57](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@GarnerP57](https://forums.unrealengine.com/u/GarnerP57)\
**Post date:** [March 28, 2024, 8:49pm UTC](https://forums.unrealengine.com/t/client-to-client-replication/1776529/4 "2024-03-28T20:49:35Z")

</div>

Yes as long as you use something the client already own like their own PlayerController.

---

<div class="post-metadata">

**Author:** ![ruigol](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/ruigol/32/964789_2.png) [@ruigol](https://forums.unrealengine.com/u/ruigol)\
**Post date:** [March 28, 2024, 8:54pm UTC](https://forums.unrealengine.com/t/client-to-client-replication/1776529/5 "2024-03-28T20:54:04Z")

</div>

Trouble ive had with player controller is that each player sees the sequence differently,  
for example:

- Player0 - is self for all players
- Player1 - for host = player1, for client = host
- Player2 - for host = player2, for client = the other client  
Making it complex and is why im getting the game state, player state, player id and passing that as the affected player and feeding it so there is some logic to who’s who

---

<div class="post-metadata">

**Author:** ![GarnerP57](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@GarnerP57](https://forums.unrealengine.com/u/GarnerP57)\
**Post date:** [March 28, 2024, 9:11pm UTC](https://forums.unrealengine.com/t/client-to-client-replication/1776529/6 "2024-03-28T21:11:05Z")

</div>

You don’t need to worry about who is who as long as you have the player id.

RunOnServer RPC from client PlayerController containing parameters for target PlayerId and command.

Server uses the playerId and command and relay it to the appropriate Character and set a replicated variable on it.

All clients use this OnRep variable to sync.

---

<div class="post-metadata">

**Author:** ![ruigol](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/ruigol/32/964789_2.png) [@ruigol](https://forums.unrealengine.com/u/ruigol)\
**Post date:** [March 28, 2024, 9:19pm UTC](https://forums.unrealengine.com/t/client-to-client-replication/1776529/7 "2024-03-28T21:19:33Z")

</div>

Is there a visual example somewhere of what you mean?

I’ve already tried casting to the host player character from client via get player character 1 (which is host) and executing the rpc from the hosts character but that didnt work and now that I type it out, of course it didnt work, the client sees a proxy of the host… right? So I need to do something with a rep notify… thats what you’re saying, ill try to consider how i can translate a repnotify to set world location (maybe via a bool that if true runs the code inside the rep notify and then sets it back to false when finished so it can happen again…) ?

---

<div class="post-metadata">

**Author:** ![GarnerP57](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@GarnerP57](https://forums.unrealengine.com/u/GarnerP57)\
**Post date:** [March 28, 2024, 9:45pm UTC](https://forums.unrealengine.com/t/client-to-client-replication/1776529/8 "2024-03-28T21:45:03Z")

</div>

I still think you are over complicating things by setting a world location manually on the clients. If you “Replicate Movement” it is handled when set by the server and you’re done.

Don’t flip a bool within rep notify? I don’t know where you are going with this.

---

<div class="post-metadata">

**Author:** ![ruigol](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/ruigol/32/964789_2.png) [@ruigol](https://forums.unrealengine.com/u/ruigol)\
**Post date:** [March 29, 2024, 1:19am UTC](https://forums.unrealengine.com/t/client-to-client-replication/1776529/9 "2024-03-29T01:19:55Z")

</div>

@Everynone you always come through, any thoughts?

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [March 29, 2024, 7:25am UTC](https://forums.unrealengine.com/t/client-to-client-replication/1776529/10 "2024-03-29T07:25:57Z")

</div>

I do not know enough about multiplayer to chip in. 😕
