Guest User

networkManager

a guest
Sep 14th, 2014
219
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public class spawnThePlayerNow : MonoBehaviour {
  2.    
  3.     public GameObject player1Prefab;
  4.     public GameObject player2Prefab;
  5.     public Transform spawnObject;
  6.     public GameObject controlBundlePrefab;
  7.     public GameObject devilPrefab;
  8.     public GameObject spawnedPlayer;
  9.    
  10.     void Start(){
  11.         spawnPlayer();
  12.     }
  13.    
  14.     void spawnPlayer(){
  15.         GameObject spawnThisPlayer;
  16.        
  17.         if(Network.isServer){
  18.             spawnThisPlayer = player1Prefab;
  19.         }
  20.         else{
  21.             spawnThisPlayer = player2Prefab;
  22.         }
  23.  
  24.         spawnedPlayer = Network.Instantiate(spawnThisPlayer,spawnObject.position,Quaternion.identity,0) as GameObject;
  25.         GameObject bundle = Instantiate(controlBundlePrefab,spawnedPlayer.transform.position,Quaternion.identity) as GameObject;
  26.         networkManager.localPlayer = spawnedPlayer;
  27.         bundle.transform.parent = spawnedPlayer.transform; //contains camera, background
  28.     }
  29. }
RAW Paste Data