Esempio n. 1
0
    public void Shoot()
    {
        EventManager.instance.TriggerOnNoiseAppeal(transform.position, noiseDistance);
        shotEffect.SetActive(true);
        audio.Play();

        RaycastHit hit;
        Ray        ray = PlayerController.instance.eyesCamera.ViewportPointToRay(new Vector3(0.5f, 0.5f, 0f));

        if (!Physics.Raycast(ray, out hit, maxDistance, ~ignoreLayers, QueryTriggerInteraction.Ignore))
        {
            return;
        }

        Shootable shootable = hit.transform.GetComponent <Shootable>();

        if (shootable)
        {
            shootable.Shot();
        }
    }