- Home /
UNET Make every player execute a function locally
What I need is that when a player presses a button every other player(and the one who pressed) execute a function but locally. For example player A presses a button, player A,B and C receive the call and the go on to do for example a raycast. I'm probably just getting the whole networking thing wrong, it sounds like a pretty basic thing
Answer by l3fty · Aug 08, 2015 at 11:16 PM
I think this is what you might want:
On the player object when the button is pressed, their client calls a [Command] method on the server, which in turn can call a [ClientRpc] on every version of that player on the network.
Then each network instance of that player could fire a local event (https://unity3d.com/learn/tutorials/modules/intermediate/scripting/events)
Which other player objects could listen for, and react to however you like. There's a little setup involved there, but it could achieve what you have described.
Your answer
Follow this Question
Related Questions
How to fix "ClientRpc call on un-spawned object" error, using UNET 2 Answers
Networking between projects: how to send ViewIDs? 1 Answer
accessing to one array from another script 2 Answers
RPC called with a viewID, reaching server with a different viewID 1 Answer
Separating Server and Client Code 0 Answers