I’ve created a script that has the intent of, when the player sees the object, after ~1 second the object will disappear.
I’m having a problem that if the player looks in the direction of the object through walls, the script will execute and the object will be gone by the time the player turns to corner to see it.
SCRIPT:
void OnBecameVisible()
{
StartCoroutine(ExampleCoroutine());
}
IEnumerator ExampleCoroutine()
{
yield return new WaitForSeconds(2);
Destroy(gameObject);
}
(Side note: I’m new to game development and scripting so sorry for any mistakes and or me not understanding a reply.)