Advertisement
KTVX94

NewPlayerIndividual

Dec 8th, 2018
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.30 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.Networking;
  5.  
  6. public class NewPlayerIndividual : NetworkBehaviour {
  7.  
  8.     public GameObject TankPrefab;
  9.     public GameObject myTank;
  10.     public int playerID;
  11.     public int posX;
  12.  
  13.  
  14.     // Use this for initialization
  15.     void Start () {
  16.  
  17.         if (!isServer)
  18.         {
  19.             playerID = MultiplayerManager.connectionID;
  20.             print(playerID.ToString());
  21.         }
  22.         if (playerID == SuperGameManager.connID) SuperGameManager.mainPlayer = this;
  23.         //Lo mando al manager en vez de hacerlo directamente para que se haga en los dos clientes
  24.         MultiplayerManager.instance.SpawnPlayer(playerID);
  25.        
  26.     }
  27.    
  28.     // Update is called once per frame
  29.     void Update () {
  30.        
  31.     }
  32.  
  33.     public void CreateTank(int connID)
  34.     {
  35.         GameObject tank = Instantiate(TankPrefab);
  36.         if (connID != playerID)
  37.         {
  38.             posX = 40;
  39.             tank.transform.position = new Vector3(posX, 1.2f, 0);
  40.         }
  41.         else
  42.         {
  43.             posX = -40;
  44.             tank.transform.position = new Vector3(posX, 1.2f, 0);
  45.             myTank = tank;
  46.             myTank.GetComponent<TankInputs>().canBeUsed = true;
  47.         }
  48.            
  49.        
  50.        
  51.  
  52.     }
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement