void Shoot() { _muzzleFlash.Trigger(); if (_lastShot + _shootRate < Time.time) { //Debug.Log("Shoot"); GameObject obj = Instantiate(projectilePrefab, _muzzle.position, _gun.rotation * Quaternion.Euler(0, 0, -90)); PlayerProjectile projectile = obj.GetComponent <PlayerProjectile>(); Player player = GetComponent <Player>(); if (projectile == null || player == null) { return; } projectile.CasterGameObject = gameObject; projectile.SetColor(player.GetColor()); _lastShot = Time.time; } }