void Awake() { object[] data = player.photonView.instantiationData; int primaryID = (int)data[0]; int secondaryID = (int)data[1]; int meleeID = (int)data[2]; int item1ID = (int)data[3]; int item2ID = (int)data[4]; if (primaryID >= 0) { primary = InstantiateGun(primaryID); } if (secondaryID >= 0) { secondary = InstantiateGun(secondaryID); } if (meleeID >= 0) { melee = InstantiateGun(meleeID); } if (item1ID >= 0) { item1 = InstantiateGun(item1ID); } if (item2ID >= 0) { item2 = InstantiateGun(item2ID); } hasStarted = true; }
public WorldModelGun InstantiateGun(int ID) { GunInfo gunInfo = GameController.GetGun(ID); GameObject go = Instantiate(gunInfo.worldmodel) as GameObject; go.name = string.Format("WM_{0}", gunInfo.Name); go.transform.SetParent(gunsParent.transform, false); go.transform.localPosition = Vector3.zero; go.transform.localRotation = Quaternion.identity; go.transform.localScale = Vector3.one; WorldModelGun gun = go.GetComponent <WorldModelGun>(); gun.info = gunInfo; gun.leftArmCharacterJoint.connectedBody = torsoRigidbody; gun.rightArmCharacterJoint.connectedBody = torsoRigidbody; CharacterCustomization customization = go.GetComponent <CharacterCustomization>(); customization.StartUp(); return(gun); }