Esempio n. 1
0
    void InstantShot(List <RaycastHit2D> _hits)
    {
        AddRecoil();

        foreach (RaycastHit2D hit in _hits)
        {
            Scuffable scuffable = hit.collider.GetComponent <Scuffable>();

            if (scuffable != null)
            {
                scuffable.Scuff(new BulletImpact(hit.point, gun.transform.right));
            }
        }
    }
Esempio n. 2
0
    void ScuffCheck(Vector3 _prev_pos, Vector3 _current_pos)
    {
        Vector3      diff = (_prev_pos - _current_pos);
        RaycastHit2D hit  = Physics2D.Raycast(_prev_pos, diff.normalized,
                                              diff.magnitude, scuffable_layer);

        if (!hit)
        {
            return;
        }

        Scuffable scuffable = hit.collider.GetComponent <Scuffable>();

        if (scuffable == null || things_scuffed.Contains(scuffable))
        {
            return;
        }

        scuffable.Scuff(new BulletImpact(hit.point, diff, expected_hit.rigidbody));
        things_scuffed.Add(scuffable);
    }