Hello, I need help with a very small piece of code. I have an object that isn’t set active. I’d like it so when space is pressed the object is set active, then after 0.5- 1 second turns off. Can anyone help?
float timer;
void Update()
{
if(timer > 0)
timer -= time.deltatime;
if (timer <= 0)
gameobject.setactive(false)
if (Input.getkey("space))
{
gameobject.setactive(true);
timer = 1f;
}
}