void Awake() { gameEnd = false; anim = GetComponent <Animator>(); playerAudio = GetComponent <AudioSource>(); gunMechanics = transform.parent.transform.GetComponentInChildren <GunMechanics>(); currentHealth = startingHealth; }
public void Awake() { PlayerAnimator = GetComponent <Animator>(); gunMechanics = GetComponent <GunMechanics>(); customCharController = GetComponent <CustomCharacterController>(); Health = 100; Time.timeScale = 1; Time.fixedDeltaTime = Time.timeScale * .01f; RestorePostProcess(); }
void Start() { if (this.gameObject.tag == "Pickup") { isPickup = true; } else { isPickup = false; } reloadAnim = false; wantedPosition = transform.localPosition; gunMech = this.gameObject.GetComponentInChildren<GunMechanics> (); anim = GetComponent<Animator>(); playerController = GetComponentInParent<PlayerController>(); Still(); }
public void AddWeapon(string weaponType, string weaponName) { GameObject WEAPON = (GameObject)GameObject.Instantiate(Resources.Load<GameObject>("Prefabs/" + ProperWeaponString(weaponName))); WEAPON.name = ProperWeaponString(weaponName); if (gunSlots[0] == null) { gunMech = WEAPON.GetComponentInChildren<GunMechanics>(); WEAPON.transform.parent = GameObject.Find("GunHolder").transform; gunSlots.SetValue(WEAPON, 0); currentWeapon = gunSlots[0]; gunMech.Start(); } else if(gunSlots[1] == null) { WEAPON.transform.parent = GameObject.Find("SecondGun").transform; gunSlots.SetValue(WEAPON, 1); secondaryWeapon = gunSlots[1]; secondaryWeapon.GetComponentInChildren<GunMechanics>().Start(); } else { if (WEAPON.name != secondaryWeapon.name) { gunMech = WEAPON.GetComponentInChildren<GunMechanics>(); WEAPON.transform.parent = GameObject.Find("GunHolder").transform; gunMech.bulletSpawn = GameObject.Find(WEAPON.name + "ModelBulletSpawn").transform; gunMech.magazineSpawn = GameObject.Find(WEAPON.name + "ModelMagazineSpawn").transform; currentWeapon.transform.parent = null; currentWeapon.name = "Trash"; gunSlots.SetValue(WEAPON, 0); foreach (Transform child in currentWeapon.transform) { child.name = "Trash"; } currentWeapon = gunSlots[0]; gunMech.Start(); } } }
// Start is called before the first frame update void Start() { player = GameObject.Find("Player"); g = new GunMechanics(transform, shotgun, source, firerate, impact, this); navMeshAgent = GetComponent <NavMeshAgent>(); }
// Start is called before the first frame update void Start() { playerRigidbody = GetComponent <Rigidbody>(); pastPlayerController = pastPlayer.GetComponent <PastPlayerController>(); g = new GunMechanics(transform, shotgun, source, firerate, impact, this); }
void SwitchWeapon() { if (Input.GetKeyDown(KeyCode.Q)) { if(gunSlots[1] != null) { GameObject.FindGameObjectWithTag("GunHolder").GetComponent<Animator>().SetBool("Switch", true); GameObject _tmp = gunSlots[0]; gunSlots.SetValue(gunSlots[1], 0); gunSlots.SetValue(_tmp, 1); gunMech = gunSlots[0].GetComponentInChildren<GunMechanics>(); } if (gunSlots[0] != null) { currentWeapon = gunSlots[0]; } if(gunSlots[1] != null) { secondaryWeapon = gunSlots[1]; } } if(GameObject.FindGameObjectWithTag("GunHolder").GetComponent<Animator>().GetBool("Switch") == false) { gunSlots[0].transform.SetParent(gunMech.PrimaryGunSlot.transform); gunSlots[1].transform.SetParent(gunMech.SecondaryGunSlot.transform); } }
void Start() { weaponNames = new List<string>(); weaponNames.Add("deagle"); weaponNames.Add("SPAS 12"); weaponNames.Add ("G36C"); weaponNames.Add("Druganov"); health = 100; gunSlots = new GameObject[2]; AddWeapon("Gun", "G36C"); AddWeapon ("Gun", "Druganov"); if (gunSlots[0] != null) { currentWeapon = gunSlots[0]; } if (gunSlots[1] != null) { secondaryWeapon = gunSlots[1]; } gunMech = currentWeapon.GetComponentInChildren<GunMechanics>(); forwards = 0f; right = 0f; jumpSpeed = 15.0f; movementSpeed = 0.03f; stoppingPower = 1.2f; maxSpeed = .15f; maxSprintSpeed = .20f; gravity = 0f; isSprinting = false; isGrounded = false; rigidBody = this.GetComponent<Rigidbody> (); crossHairs = GameObject.Find ("CH").GetComponent<Crosshairs> (); camera = GameObject.Find ("Main Camera").GetComponent<Camera>(); }
private void Awake() { gunMechanics = GetComponent <GunMechanics>(); }