Im trying to make a short script where when you start the object is de-activated, and if the time is = 2 seconds, it will set the gameObject to active, but I can’t figure out how. (I’m 100% noobish to unity so this is probably a dumb question.)
function Start()
{
gameObject.SetActive(false);
}
function Update () {
if (Time.time = 2)
{
gameObject.SetActive(true);
}
}
Firstly I’m pretty sure you need two = signs when doing a comparison, single = is assignment, not entirely certain about javascript so correct me if I’m wrong.
The reason it’s probably not working is because Time.time is a float, decimal, so very unlikely to even be exactly 2. Use an inequality instead e.g. Time.time > 2
Another thing to note, this needs to be called from a script which is not attached to the object otherwise this script will be disabled and so unable to perform its check or reactivate the object!