I want to create a script that destroys the bullet decal after a certain amount of time but only if the player is not looking at it. The decal is a prefab spawned by another script. Here’s my script
#pragma strict
var respawnTimer = 0;
var delayTime = 10;
function Update() {
respawnTimer += Time.deltaTime;
if (respawnTimer > delayTime) {
if (!renderer.isVisible) {
Destroy(this.gameObject);
}
}
}
I don’t really know why it isn’t working but i hope you can help me. Thanks!