- Home /
Question by
Diamonddoggames · Dec 23, 2019 at 04:55 PM ·
delay
Trying to add a delay to this script
Im trying to use a delay to the animation playing then adding the ammo back. But for some reason I can't add the delay. idk I guess im bad at coding
if (ammoL <= 0f) { animationR(); //wait addAmmo(); }
Comment
mm.. I'm not sure what you mean but try using animation event. through an animation event, you will set an event at a specific frame in your animation. when an animation is playing at that frame will fire you event you had specified (Function Call)
if you want you can do it in another way and its using coroutine
Answer by ZozeR · Dec 23, 2019 at 05:22 PM
Try using Coroutines
You can simply create a delay by doing:
//in your function
StartCoroutine(Delay_Fade(2f));
//declare the Delay_Fade
IEnumerator Delay_Fade(float ct)
{
yield return new WaitForSeconds(ct);
//this part will be called after 2sc write anything you want
}
Your answer
