private void LaunchProjectile() { if (!UIHandler.Instance.isPause) { Vector3 mousePosition = mainCamera.ScreenToWorldPoint(new Vector3(Input.mousePosition.x, Input.mousePosition.y, mainCamera.nearClipPlane)); Vector3 point = mainCamera.transform.position + (mousePosition - mainCamera.transform.position).normalized * intersectionPoint; Vector3 direction = (point - transform.position).normalized; var look = Quaternion.LookRotation(direction); float gunAngle = look.eulerAngles.y; float gunAngleX = look.eulerAngles.x; if (IsBetween(minRotationAngle, maxRotationAngle, gunAngle)) { transform.rotation = Quaternion.Euler(transform.rotation.eulerAngles.x, gunAngle, transform.rotation.eulerAngles.z); } if (IsBetween(minAngleX, maxAngleX, gunAngleX)) { transform.rotation = Quaternion.Euler(gunAngleX, transform.rotation.eulerAngles.y, transform.rotation.eulerAngles.z); } if (!CanShoot()) { return; } if (Input.GetMouseButtonDown(0) && isReadyToShoot && !IsPointerOverUIObject()) { Bullet prefab = ammo.GetBullet(); var bullet = Instantiate(prefab, shootPoint.position, Quaternion.identity); bullet.SetVelocity(transform.forward * speed); shootPs.Play(); SoundController.Instance.PlaySound(SoundController.Instance.shootSound); if (bullet.CompareTag("superBall")) { SoundController.Instance.PlaySound(SoundController.Instance.shootSuperBall); } StartCoroutine(ReadyToShoot()); bullCounter++; } } }