So I have tried to add bullet penetration. Take a look:
private bool isPenetrating;
void OnEnable()
{
isPenetrating = (Random.value > 0.5f);
}
void OnTriggerEnter(Collider col)
{
if (isPenetrating)
isPenetrating = false;
else
Disable();
}
void Disable()
{
gameObject.SetActive(false);
gameController.bulletPool.Enqueue(this.gameObject);
}
The bullet is a trigger. If the bullet collides with something and it is supposed to penetrate, then it will not disable the object and it will turn off the ability to penetrate. When it hits another object, then it will disable. When it is reenabled, then it will have a 50% chance to be able to penetrate.
It does not work! It wont pass through the object at all.