Ejemplo n.º 1
0
        public void OnRotationDataReceived(Data_Rotation rotationData)
        {
            if (rotationData.Id != _id)
            {
                return;
            }
            var newRot = rotationData.Rotation;

            if (syncRotInterpolate)
            {
                _interpolateRot = newRot;
            }
            else
            {
                transform.rotation = newRot;
                _oldRot            = transform.rotation;
            }
        }
Ejemplo n.º 2
0
        private void OnRotationDataReceived(Data_Rotation data)
        {
            if (!_networkObjects.ContainsKey(data.Id))
            {
                Debug.LogError($"Could not find network object with id: {data.Id}");
                return;
            }
            NetworkObject networkObject = _networkObjects[data.Id];
            SyncTransform syncTransform = networkObject.GetComponent <SyncTransform>();

            if (syncTransform && !data.Instantly)
            {
                syncTransform.OnRotationDataReceived(data);
            }
            else
            {
                networkObject.transform.rotation = data.Rotation;
            }
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Synchronize all network objects with client
 /// </summary>
 /// <param name="client">Client to synchronize</param>
 private void Synchronize(ConnectedClient client)
 {
     foreach (var networkObject in _networkObjects.Values)
     {
         if (networkObject.PrefabIndex != -1)
         {
             var spawnData = new Data_Spawn()
             {
                 PrefabIndex = networkObject.PrefabIndex,
                 Position    = networkObject.Position,
                 Rotation    = networkObject.Rotation
             };
             _dataPackets[client.Id].Add(spawnData);
         }
         else
         {
             var posData = new Data_Position()
             {
                 Id        = networkObject.Id,
                 Position  = networkObject.Position,
                 Instantly = true
             };
             _dataPackets[client.Id].Add(posData);
             var rotData = new Data_Rotation()
             {
                 Id        = networkObject.Id,
                 Rotation  = networkObject.Rotation,
                 Instantly = true
             };
             _dataPackets[client.Id].Add(rotData);
             var sclData = new Data_Scale()
             {
                 Id        = networkObject.Id,
                 Scale     = networkObject.Scale,
                 Instantly = true
             };
             _dataPackets[client.Id].Add(sclData);
         }
     }
 }