- Home /
broadcast network
Hello everybody, I would like to know how to send a message to all network applications(unity of course ), such as a P2P? Without a structure for client and server.
not sure you can even do it without a server client relationship. functions like RPC only work when connected.
can i make a server send a message to all clients? Or even a client tell the server to do this?
yes, Its called RPCs. It works kind of like Broadcast message but requires a few extra steps. It allows you to send the command to Execute a function, send Strings, Vector3s, floats and int. you can send as many as you want so its very useful.
Team, i did it: 1ª Created one game object 2º Add networkview from component- miscellaneous 3º Created script
function Update() { networkView.RPC("print", RPC$$anonymous$$ode.All, "go!"); }
@RPC function print(text : String) { Debug.Log(text); }
4º Attached script in gameobject 5º Build & Run 6º Execute in Unity Editor.
Result on console : "Can't send RPC function since no connection was started."
What can i do to work?
Answer by flamy · Dec 14, 2011 at 05:29 AM
host a server first and make the peers connect to it Network.Conenct then call this rpc after connecting!! if u r already calling connect check for the errors messages!
and also add if((Network.isServer)||(Network.isClient)) before ur Rpc call in update.
I would suggest u to take a look into some basic network tutorials like this
Sorry, i didn't understand it "for which u can download the source code and all setup instruction from unity website free!" how can i do it?
for the masterserver! take a look at this page http://unity3d.com/support/documentation/Components/net-$$anonymous$$asterServerBuild.html for buildin masterserver
and this page for download! http://unity3d.com/master-server/index.html
Answer by ric_eng · Dec 14, 2011 at 11:21 AM
I had to follow creating a server, but the bad part is that whenever the need for the client server IP. Would make the client scan the network looking for a server and then find the IP connection and ask him?,
if u dont want the user to enter ip everytime use "$$anonymous$$asterServer", it will poll the host ip online and would enable it to access it from anywhere, but this would make ur game require internet facility! if u dont want this to go online, u have to maintain the masterserver locally, for which u can download the source code and all setup instruction from unity website free!
Your answer
Follow this Question
Related Questions
UNET - Broadcast Data from Android changes when PC joins Network 1 Answer
Broadcast data not updating. 1 Answer
Iphone UDP Server Discovery 0 Answers
Override Network View ID 1 Answer