Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using FishNet.Object;
- using FishNet.Object.Synchronizing;
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class GamePlayManager : NetworkBehaviour
- {
- public static GamePlayManager Instance;
- // Synct Objecte im netzwerk
- [field: SyncObject]
- public readonly SyncList<Player> players = new SyncList<Player>();
- [SerializeField]
- GameObject playerModel; // Dev later localPlayerdta
- bool canSpawn = true;
- private void Awake()
- {
- Instance = this;
- }
- private void Update()
- {
- if(IsServer)
- {
- return;
- }
- if (canSpawn)
- {
- Debug.Log("I can spawn");
- SpawnNewItem();
- canSpawn = false;
- }
- }
- [Server]
- void SpawnNewItem()
- {
- Debug.Log("Spawn!");
- GameObject Player = Instantiate(playerModel);
- // ownership to Player
- ServerManager.Spawn(Player, players[0].Owner);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement