Shorter Code to Hide the Falling Objects before the Fall

What I did, I unchecked the Tick Marks of the Mash Renderer and Use Gravity in the Inspector and used below code before watching the Video and it worked fine. I don’t know if it is the Right approach but the code is shorter. Please advise

public class Dropper : MonoBehaviour

{

[SerializeField] float timeElapsed = 3;

// Start is called before the first frame update

void Start()

{

   

}

// Update is called once per frame

void Update()

{

   

    if (Time.time > timeElapsed){

    GetComponent<MeshRenderer>().enabled = true;

    GetComponent<Rigidbody>().useGravity = true;

}

}

}

Privacy & Terms