// Use this for initialization void Awake() { singleton = this; netManager = PhaNetworkManager.Singleton; PhantomSpawnLocation[] tempSpawnLocations = GetComponentsInChildren <PhantomSpawnLocation>(); size = tempSpawnLocations.Length; ListOfPhantomSpawners = new List <PhantomSpawnLocation>(size); phantoms = new GameObject[size]; PreviousPositions = new Vector3[size]; for (int i = 0; i < size; i++) { ListOfPhantomSpawners.Add(tempSpawnLocations[i]); } size = 0; }
void SpawnPlayer(Scene _scene1, Scene _scene2) { if (_scene2.name != "Menu") { if (characterSelection == 0) { Ishost = true; AgentSpawned = GameObject.Instantiate(AgentPrefab); //Local player is agent. AgentHealth = AgentSpawned.GetComponent <Health>(); AgentRigidBody = AgentSpawned.GetComponent <Rigidbody>(); previousPlayerVelocity = new Vector3(AgentRigidBody.velocity.x, AgentRigidBody.velocity.y, AgentRigidBody.velocity.z); previousPlayerRotation = new Quaternion(AgentSpawned.transform.rotation.x, AgentSpawned.transform.rotation.y, AgentSpawned.transform.rotation.z, AgentSpawned.transform.rotation.w); SpawnedHacker = GameObject.Instantiate(RemoteHackerPrefab); } else if (characterSelection == 1) { Ishost = false; AgentSpawned = GameObject.Instantiate(RemoteAgentPrefab); AgentHealth = AgentSpawned.GetComponent <Health>(); Vector3 startPosition = FindObjectOfType <PlayerStartLocation>().transform.position; AgentSpawned.transform.position = new Vector3(startPosition.x, startPosition.y, startPosition.z); AgentSpawned.GetComponent <NetworkedMovement>().receivedPosition = new Vector3(startPosition.x, startPosition.y, startPosition.z); AgentRigidBody = AgentSpawned.GetComponent <Rigidbody>(); AgentPrediction = AgentSpawned.GetComponent <NetworkedBehaviour>(); SpawnedHacker = GameObject.Instantiate(HackerPrefab); //Local Player is Hacker. The order of instantiation here is important! } phantomManager = FindObjectOfType(typeof(PhantomManager)) as PhantomManager; if (phantomManager == null) { Debug.LogError("phantomManager not found. F**k."); } //skipeManager.startSkipe(); } else { int bytesreceived = 0; do { bytesreceived = PhaNetworkingAPI.ReceiveFrom(PhaNetworkingAPI.mainSocket, receiveBuffer, recvBufferSize); Debug.Log("Continuing to flush the f*****g buffer, bytes: " + bytesreceived); } while (bytesreceived != 10035); //skipeManager.closeSkipe(); } }