Пример #1
0
    void Bounce(Vector3 collisionNormal)
    {
        bounce++;
        //play particle system
        GameObject shotParticle = Instantiate(explosion, gameObject.transform.position, Quaternion.identity);

        Destroy(shotParticle, 3f);

        if (gameObject.CompareTag(_PROJECTILE1_TAG))
        {
            _type1.SetBounces(bounce);
        }

        if (gameObject.CompareTag(_PROJECTILE2_TAG))
        {
            _type2.SetBounces(bounce);
        }

        var bounceSpeed = _shootDir.magnitude;
        var direction   = Vector3.Reflect(_shootDir.normalized, collisionNormal);

        _shootDir = direction * bounceSpeed;
    }