SO I’ve managed to make a script in which when a visible wall collides with the player’s bullet it will disable the renderer & collider for 6 seconds before reappearing. Now I want to make a secondary script which makes invisible walls with their colliders & renderers disabled and upon collision/detection of a bullet passing through, it enables both renderers & colliders for a specific set of time or until the player shoots the wall again to make it disappear.
The code for making the wall invisible is shown here:
function OnTriggerEnter(col : Collider) {
if (col.tag == "Bullet") { //If it is the bullet entering the collider
renderer.enabled = false;
collider.enabled = false;
Invoke ("ReEnable",5); //Re-enable it in 10 seconds
}
}
function ReEnable() {
renderer.enabled = true;
collider.enabled = true;
}
The main problem I’ve been encountering is that when the collider is disabled firstly when a bullet is shot pass it won’t detect the collision to enable the collider & renderer as the collider isn’t turned on in the first place.
Any ideas?