- Home /
Question by
unity_2003el612003fy9 · Mar 22, 2021 at 11:57 PM ·
scripting beginnerdisableenablemesh rendererseconds
How to enable an object's mesh renderer 8 seconds after the scene starts?
By default, I have the object's mesh renderer disabled. I need it to automatically enable itself after 8 seconds has passed after the scene has begun.
I can't seem to find any answers online to anything similar to my question. I am not a programmer by any means and have zero knowledge on C#. If someone could lend me a hand by writing this script for me, I'd be very thankful!
Comment
Best Answer
Answer by $$anonymous$$ · Mar 23, 2021 at 12:40 AM
Here is the script
Make sure to assign the object you want to render in 8 seconds
Make sure that the mesh rendered is disabled
Make sure that the script is sitting on an object any object
` using System.Collections; using System.Collections.Generic; using Unity Engine;
public class Anything : MonoBehaviour
public GameObject object;
void Awake ()
{
StartCoroutine (AfterTime ());
}
IEnumerator AfterTime ()
{
yield return new waitforsconds (8f);
object. GetComponent <meshrendered>().enable = true ;
}