Ejemplo n.º 1
0
    private void Shoot()
    {
        animControl.Shoot();
        line.SetActive(false);
        invoker.Invoke(.6f, SetLineActiveIfAiming);

        GameObject newShot = Instantiate(shot, shot.transform.parent);

        newShot.transform.parent = null;
        RaycastHit hit;
        Ray        ray        = new Ray(shot.transform.position, shot.transform.forward);
        bool       hitSuccess = Physics.Raycast(ray, out hit, 9);

        SetUpShotVisuals(newShot, hitSuccess, hitSuccess ? hit.point : Vector3.zero);

        if (hitSuccess)
        {
            GameObject go = hit.collider.gameObject;
            if (go.tag.Equals("Enemy"))
            {
                go.GetComponent <EnemyAnimationControl>().PlayDeathAnim(hit.point, shot.transform.forward);
            }
        }

        newShot.SetActive(true);
        newShot.AddComponent <FadeLineOutControl>();
    }