Problem with LAN multiplayer game in Unity

July 30   unity 0 0 Views
Advertisement

I'm trying to learn how to make an offline LAN multiplayer game in Unity.

So for example, I make something that can send a text message and make a cube XD

Now this is my problem:

Problem with LAN multiplayer game in Unity

(When I send a message, try connecting to the server, or when I try to create a cube I should first click on the other window!)

StartServer:

    using UnityEngine; using System.Collections;  public class StartServer : MonoBehaviour {     public Transform Taghsimobj;     public Transform Makan;     public Transform CubeOBJ;      public string MSG;      public string ResMsg;      void Ress (string inres) {         ResMsg = inres;      }      void OnGUI () {          if (Network.peerType == NetworkPeerType.Disconnected)         {             if (GUILayout.Button ("StartServer"))             {                 Network.InitializeServer(10, 25000);             }             if (GUILayout.Button ("Connect"))             {                 Network.Connect ("192.168.1.101", 25000);             }          }          else          {             if (GUILayout.Button ("CreatCube"))             {                 Network.Instantiate (CubeOBJ, Makan.transform.position, Makan.transform.rotation, 0);             }             if (GUILayout.Button ("CreatChat"))             {                 Network.Instantiate (Taghsimobj, this.transform.position, this.transform.rotation, 0);             }             if (GUILayout.Button ("SendMessage"))             {                 GameObject.Find ("GameObject(Clone)").GetComponent<NetworkView>().RPC ("ResText", RPCMode.All, MSG);             }             MSG=GUILayout.TextField(MSG);                GUILayout.Box (ResMsg);         }       } } 

taghsim:

    using UnityEngine; using System.Collections;  public class Taghsim : MonoBehaviour {      void Start () {     }      [RPC]     void ResText (string ResIn) {         GameObject.Find ("Main Camera").SendMessage ("Ress", ResIn);      } } 
Advertisement

Replay

Tags: unity
PC site About | Contact

©2016 avrocks.com all rights reserved

processed in 0.094 (s). 5 q(s)