Client to client replication???

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:


It gets populated with these buttons, and the information to identify each player

The spawned button has this logic to pass along the correct player identifying integer

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

Now in the player character i have a custom event triggering an event run on the server

…get your glasses on for this…
the server event triggers a multipcast event which tells the affected player to teleport

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.

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.

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?

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

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

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.

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…) ?

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.

@Everynone you always come through, any thoughts?

1 Like

I do not know enough about multiplayer to chip in. :confused: