/// <summary>
        ///     Destroys given object.
        /// </summary>
        /// <param name="obj">Object to destroy.</param>
        public static void Destroy(QNetObjectBehaviour obj)
        {
            if (obj == null)
            {
                return;
            }
            if (!QNetManager.IsServerActive)
            {
                throw new InvalidOperationException("You can only destroy QNetObjects from server.");
            }

            // send destroy message to all connections
            QNetServerObjects.DestroyObjectOnAllConnections(obj);

            // and then destroy this object on local machine
            InternalDestroy(obj);
        }
        /// <summary>
        ///     Spawns new object in world by QNet.
        /// </summary>
        /// <param name="prefab">Prefab of object to spawn.</param>
        /// <param name="position">Position of object to spawn.</param>
        /// <param name="rotation">Rotation of object to spawn.</param>
        /// <param name="ownerIdentity">Identity of owner.</param>
        /// <param name="skipObjectBroadcast">If true, system will skip SendObjectToAllConnection method.</param>
        public static QNetObjectBehaviour SpawnWithOwner(QNetObjectPrefab prefab, Vector3 position, Quaternion rotation,
                                                         short ownerIdentity, bool skipObjectBroadcast = false)
        {
            if (!QNetManager.IsServerActive)
            {
                throw new InvalidOperationException("You can only spawn QNetObjects from server.");
            }

            // then spawn local instance of object to make sure that everything is ok.
            var behaviour = InternalSpawn(GenerateObjectIdentity(), prefab, position, rotation, ownerIdentity);

            if (behaviour == null)
            {
                return(null);
            }

            if (!skipObjectBroadcast)
            {
                QNetServerObjects.SendObjectToAllConnections(behaviour);
            }

            return(behaviour);
        }