private void DoAttack() { if (cooldownShoot > 0) { return; // too soon } if (!wantsToTarget) { return; // player not targeting } if (!wantsToAttack) { return; // player not attacking } if (target == null) { return; // no target } if (!CanSeeThing(target)) { return; } HealthSystem targetHealth = target.GetComponent <HealthSystem>(); if (targetHealth) { targetHealth.TakeDamage(20); } cooldownShoot = 1 / roundsPerSecond; // attack! camOrbit.Shake(.5f); if (handL) { Instantiate(prefabMuzzleFlash, handL.position, handL.rotation); } if (handR) { Instantiate(prefabMuzzleFlash, handR.position, handR.rotation); } // moves arms up armL.localEulerAngles += new Vector3(-20, 0, 0); armR.localEulerAngles += new Vector3(-20, 0, 0); //moves arms backwards armL.position += -armL.forward * .1f; armR.position += -armR.forward * .1f; SoundEffectBoard.PlayPlayerShot(); }