/// <summary>
 /// Unregister this object on the network
 /// </summary>
 void UnregisterSelf()
 {
     NetworkManager.UnregisterNetworkObject(this);
     NetworkManager.SendDataToServer(new Data_Unregister()
     {
         Id = networkId
     });
 }
Esempio n. 2
0
        private void FixedUpdate()
        {
            _fixedUpdateFrameCounter++;
            if (syncPosition)
            {
                if (syncPosFrequency % _fixedUpdateFrameCounter == 0)
                {
                    if (_oldPos != transform.position)
                    {
                        NetworkManager.SendDataToServer(new Data_Position()
                        {
                            Id       = _id,
                            Position = transform.position
                        });
                        _oldPos = transform.position;
                    }
                }
            }

            if (syncRotation)
            {
                if (syncRotFrequency % _fixedUpdateFrameCounter == 0)
                {
                    if (_oldRot != transform.rotation)
                    {
                        NetworkManager.SendDataToServer(new Data_Rotation()
                        {
                            Id       = _id,
                            Rotation = transform.rotation
                        });
                        _oldRot = transform.rotation;
                    }
                }
            }

            if (syncScale)
            {
                if (syncSclFrequency % _fixedUpdateFrameCounter == 0)
                {
                    if (_oldScl != transform.localScale)
                    {
                        NetworkManager.SendDataToServer(new Data_Scale()
                        {
                            Id    = _id,
                            Scale = transform.localScale
                        });
                        _oldScl = transform.localScale;
                    }
                }
            }

            if (_fixedUpdateFrameCounter >= 50)
            {
                _fixedUpdateFrameCounter = 0;
            }
        }
 /// <summary>
 /// Register this object on the network
 /// </summary>
 void RegisterSelf()
 {
     NetworkManager.RegisterNetworkObject(this);
     NetworkManager.SendDataToServer(new Data_Register()
     {
         Id             = networkId,
         PrefabIndex    = prefabIndex,
         OwningPlayerId = owningPlayerId
     });
 }