Пример #1
0
    private void OnTriggerStay2D(Collider2D collision)
    {
        Vector2 dir = collision.transform.position - transform.position;

        Gunner g = collision.GetComponent <Gunner>();

        if (g)
        {
            if (g.Friendly == m_Friendly)
            {
                return;
            }

            g.Push(transform.right * m_Knockback * Strength);
        }

        Bullet b = collision.GetComponent <Bullet>();

        if (b)
        {
            if (b.Friendly == m_Friendly)
            {
                return;
            }

            b.RigidBody.AddForce(dir.normalized * m_Knockback, ForceMode2D.Impulse);
        }
    }