Answer the question
In order to leave comments, you need to log in
What to do if the coroutine does not start?
I wanted to create a loop with a delay, but after looking at a lot of guides, I got this result:
private void OnChangingItem(ChangingItemEventArgs ev)
{
if (Check(ev.NewItem))
{
if (ev.Player.Health < 50)
{
ev.Player.AddItem(ItemType.SCP500);
Timing.RunCoroutine(Healing());
//return;
}
}
}
private IEnumerator<float> Healing()
{
ev.Player.AddItem(ItemType.SCP018);
Player.AddItem(ItemType.SCP207);
while (true)
{
ev.Player.AddItem(ItemType.SCP268);
Player.Health++;
yield return Timing.WaitForSeconds(3f);
}
}
Answer the question
In order to leave comments, you need to log in
Coroutines are started as: StartCoroutine(Healing());
What is Timing? write simply: yield return new WaitForSeconds(3f);
With this logic, you will start a new coroutine every time you have OnChangingItem. You can try stopping this before running it again: StopCoroutine(Healing())
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question