public void Detach(GameObject weapon, WeaponDB.Weapons refWeapon) { weapon.transform.SetParent(Spine, false); weapon.transform.localPosition = refWeapon.spinePos; weapon.transform.localEulerAngles = refWeapon.spineRot; int pID = photonView.ViewID; photonView.RPC("SetWeaponSpineParent", RpcTarget.Others, pID, weapon.GetComponent <PhotonView>().ViewID, refWeapon.spinePos, refWeapon.spineRot, weapon.transform.localScale ); PhotonNetwork.SendAllOutgoingCommands(); }
void Start() { if (!photonView.IsMine) { return; } player = GetComponent <PlayerController>(); anim = GetComponent <Animator>(); aimOffset = Vector3.zero; currWeapons = new List <WeaponDB.Weapons>(); currWeapons.Add(WeaponDB.instance.GetWeaponByName("M4A1")); currWeapons.Add(WeaponDB.instance.GetWeaponByName("AK47")); currWeapons[0].currBullets = currWeapons[0].bullets; currWeapons[0].currReserve = currWeapons[0].reserve; currWeapons[1].currBullets = currWeapons[1].bullets; currWeapons[1].currReserve = currWeapons[1].reserve; currWeapon = currWeapons[0]; currWeapon.go = PhotonNetwork.Instantiate(currWeapon.prefab.name, currWeapon.prefab.transform.position, currWeapon.prefab.transform.rotation); Detach(currWeapon.go, currWeapon); currWeapon = null; }
public void Attach(GameObject weapon, WeaponDB.Weapons refWeapon) { nextFire = 0; nextRecoil = 0; recoilTimer = 0; currWeapon.currRecoilStrength = 0; aimOffset = Vector3.zero; weapon.transform.SetParent(rightHand, false); weapon.transform.localPosition = refWeapon.handPos; weapon.transform.localEulerAngles = refWeapon.handRot; int pID = photonView.ViewID; photonView.RPC("SetWeaponHandParent", RpcTarget.Others, pID, weapon.GetComponent <PhotonView>().ViewID, refWeapon.handPos, refWeapon.handRot, weapon.transform.localScale ); PhotonNetwork.SendAllOutgoingCommands(); }