public void Attack() { BulletScript Temp = Instantiate(projectile).GetComponent <BulletScript>(); Temp.transform.position = transform.position; if (Temp != null) { Temp.Initialize(PlayerInfo.Instance.playerPos.position - transform.position, projectileSpeed, false, this.gameObject); GetComponent <AudioSource>().PlayOneShot(soundEffect, AudioManager.Instance.sfxVolume); } timeToShoot = shotTimer; }
/// <summary> /// Attacks with a ranged weapon /// </summary> public void Attack() { if (timeToShoot <= 0f && PV.IsMine) { muzzleFlash.SetActive(true); BulletScript Temp = PhotonNetwork.Instantiate(Path.Combine("PhotonPrefabs", "PlayerBullet"), new Vector3(0, 0, 0), Quaternion.identity).GetComponent <BulletScript>(); Temp.transform.position = transform.position + (camera2.ScreenToWorldPoint(Input.mousePosition) - transform.position).normalized * 1.5f; if (Temp != null) { Temp.Initialize(camera2.ScreenToWorldPoint(Input.mousePosition) - transform.position, projectileSpeed, true, this.gameObject); GetComponent <AudioSource>().PlayOneShot(soundEffect, AudioManager.Instance.sfxVolume); } timeToShoot += 60f / roundsPerMinute; GetComponent <PlayerWeaponController>().firing = false; } }