/// <summary> /// Accept player /// </summary> /// <param name="request">join request</param> private void AcceptPlayer(JoinGroupRequest request) { IPeer peer = request.Accept("SimpleGame"); // check if peer is connected if (peer.isConnected) { GameObject go = Instantiate(boxPrefab); go.SetActive(true); ServerSimpleBox component = go.GetComponent <ServerSimpleBox>(); component.id = peer.Id; boxes.Add(component.id, component); } }
/// <summary> /// Create box prefab /// </summary> /// <returns>box prefab game object</returns> public GameObject CreateBoxPrefab() { GameObject prefab = CreateGameObject(); prefab.Name = "Box"; // add simple box component ServerSimpleBox component = prefab.AddComponent <ServerSimpleBox>(); component.moveSpeed = 3f; // add collider component BoxCollider collider = prefab.AddComponent <BoxCollider>(); collider.SetSize(new Vector3(1f)); prefab.SetActive(false); return(prefab); }