Delay Invisibility

Hi

I wanted to know how to delay a line of code from activating for a ceratin amount of time

It’s function is basically to 1: allow me to swap a weapon out of sight

and 2: when a certain number of seconds have passed make the object invisible.

I have looked into the “WaitForSeconds” type but haven’t had much luck in using it.

Ideally It would be great to make a method that delayed the invisibility so I could just call it up as and when i need it (which I tried doing)…

void wait(){}

IEnumerator WaitUp(){



	{

		yield return new WaitForSeconds(10);

		print("im_not_doing_anything");

	}

	

}

So firstly am I using this correctly and is there a better more effective way of pulling this off for instance maybe something like a “wait until animation is played” function similar to the animation “QueMode’s” but for invisibility?

I’m not sure what the issue is. What problem are you having with the coroutine? It looks fine to me.

I guess what you want is a public method which can called from anywhere which will then begins a private coroutine?

// Public method to begin wait coroutine
public void Wait() {
	StartCoroutine(wait());
}

private IEnumerator wait() {
	yield return new WaitForSeconds(10);
	
	// Do Stuff
}

Thanks that’s exactly what i was trying to do and it works nicely.