예제 #1
0
    private void OnCollisionEnter(Collision collision)
    {
        BulletCollider bulletCollider = collision.collider.GetComponent <BulletCollider>();

        if (bulletCollider)
        {
            ProjectileWeapon weapon = bulletCollider.GetComponent <ProjectileWeapon>();
            //dont do anything if this projectile collides with
            //the person who shot it
            if (weapon != firerWeapon)
            {
                bulletCollider.BulletCollision(this);

                if (bulletCollider.KillBullet)
                {
                    Kill();
                }
                else
                {
                    //It has a bullet collider but is set to not 'kill' the bullet.
                    //so we assume the bullet should 'Bounce' off the surface
                    foreach (ContactPoint c in collision.contacts) //Find collision point
                    {
                        rigid.velocity          = Quaternion.AngleAxis(180, c.normal) * transform.forward * -1;
                        rigid.velocity          = rigid.velocity.normalized * speed * timeManager.Coefficient;
                        rigid.transform.forward = rigid.velocity.normalized;
                    }
                }
            }
        }
    }
예제 #2
0
    private void OnTriggerEnter(Collider other)
    {
        BulletCollider bulletCollider = other.GetComponent <BulletCollider>();

        if (bulletCollider)
        {
            ProjectileWeapon weapon = bulletCollider.GetComponent <ProjectileWeapon>();
            //dont do anything if this projectile collides with
            //the person who shot it
            if (weapon != firerWeapon)
            {
                bulletCollider.BulletCollision(this);

                if (bulletCollider.KillBullet)
                {
                    Kill();
                }
            }
        }
    }