void Fire() { animator.SetTrigger("Shoot"); audioSource.PlayOneShot(shootingAudio); canShoot = false; cooldown = 1 / playerAttributes.GetCurFireRate(); // Summon bullet Plane plane = new Plane(Vector3.up, transform.position); Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); if (plane.Raycast(ray, out float distance)) { Vector3 pointInWorld = ray.GetPoint(distance); Vector3 direction = pointInWorld - transform.position; Quaternion bulletRotation = Quaternion.LookRotation(direction, Vector3.up); var instance = Instantiate(bulletPrefab, bulletSummonPosition.position, bulletRotation * bulletPrefab.transform.rotation); BulletBase firedBullet = instance.GetComponent <BulletBase>(); firedBullet.SetDamage(playerAttributes.GetCurDamage()); firedBullet.SetSpeed(playerAttributes.GetCurProjSpeed()); } else { Debug.Log("Raycast from mouse pos failed in " + name); } }