Esempio n. 1
0
 void Start()
 {
     if (isServer)
     {
         idCount++;
         id = idCount;
     }
     if (isPlayer)
     {
         id = 0;
     }
     objSync  = new ObjectSync(id, prefabId);
     position = new PositionSync(id, transform.position);
     rotation = new RotationSync(id, transform.rotation);
     if (!isServer)
     {
         ViewerManager.instance.synchronizables.Add(this);
     }
     if (isServer)
     {
         StartCoroutine(SyncPos());
         StartCoroutine(SyncRot());
         NetworkManager.instance.SendJSON("newenemy", JsonUtility.ToJson(objSync));
     }
 }
Esempio n. 2
0
        public void Receive_Rotation(SocketIOEvent e)
        {
            RotationSync rotation = JsonUtility.FromJson <RotationSync> (e.data.ToString());

            for (int i = 0; i < synchronizables.Count; i++)
            {
                if (synchronizables [i].id == rotation.id)
                {
                    if (synchronizables [i].syncRotation)
                    {
                        synchronizables [i].transform.rotation = Quaternion.Euler(new Vector3(rotation.rotX, rotation.rotY, rotation.rotZ));
                    }
                }
            }
        }