Beispiel #1
0
    // Start is called before the first frame update
    void Start()
    {
        PlayerPrefs.SetInt("Server", 0);

        players = new List <Player>();
        objects = new List <Object>();

        scene  = GameObject.Find("Game").gameObject;
        player = GameObject.Find("Player").gameObject;
        body   = player.GetComponent <Rigidbody>();
        syncServerDownPlayer = player.GetComponent <SyncServerDown>();

        playerSync = new Player();
        playerSync.transform.name     = Name.text;
        playerSync.transform.position = Respawn.transform.position;
        syncServerDownPlayer.SetPlayer(playerSync);

        client = new UdpClient(IP, Port);

        // Create thread for reading UDP messages
        readThread = new Thread(new ThreadStart(ReceiveData));
        readThread.IsBackground = true;
        readThread.Start();

        isInit = true;
    }
Beispiel #2
0
    // Start is called before the first frame update
    void Start()
    {
        currentRotation = transform.eulerAngles;

        game       = GameObject.Find("Game").gameObject.GetComponent <Game>();
        body       = GetComponent <Rigidbody>();
        syncPlayer = GetComponent <SyncServerDown>();
        position   = gameObject.transform.position;
    }
Beispiel #3
0
 private void AddPlayer(Player _player)
 {
     if (scene != null)
     {
         GameObject __player = Instantiate(TemplatePlayer, scene.transform, false);
         __player.transform.localPosition = Respawn.transform.localPosition;
         SyncServerDown __syncPlayer = __player.GetComponent <SyncServerDown>();
         __syncPlayer.SetPlayer(_player);
         _player.Create(__player);
         _player.Add();
     }
 }