Esempio n. 1
0
        /// <summary>
        /// The character should spawn. Override Spawn to allow the SpawnSelection component determine the location that the character should spawn.
        /// Call the corresponding server or client method.
        /// </summary>
        public override void Spawn()
        {
#if ENABLE_MULTIPLAYER
            // On the network the client may have disconnected and the Respawner is no longer valid.
            if (this == null)
            {
                return;
            }
#endif

            var location = SpawnSelection.GetSpawnLocation();

#if ENABLE_MULTIPLAYER
            if (isServer)
            {
                RpcSpawn(location.position, location.rotation);
            }
            // Execute the method on the local instance. Use isClient instead of isServer because the client and server may be the same instance
            // in which case the method will be called with the Rpc call.
            if (!isClient)
            {
#endif
            SpawnLocal(location.position, location.rotation);
#if ENABLE_MULTIPLAYER
        }
#endif
        }
Esempio n. 2
0
 /// <summary>
 /// Assign the static variables.
 /// </summary>
 protected virtual void Awake()
 {
     s_Instance = this;
 }