Answer the question
In order to leave comments, you need to log in
How to consider the time of a coroutine relative to the second coroutine?
How to consider the time of a coroutine relative to the second coroutine? That is, the first coroutine was executed, 2 seconds passed and the second coroutine was executed, 2 seconds passed relative to the second - the first one was executed, and so on.
public class activeplatform : MonoBehaviour
{
public bool on;
Collider2D coll;
private void Start()
{
StartCoroutine(corout());
StartCoroutine(corout2());
coll = GetComponent<Collider2D>();
}
IEnumerator corout()
{
while (true)
{
yield return new WaitForSeconds(2);
gameObject.GetComponent<Renderer>().material.color = Color.red;
coll.enabled = false;
}
}
IEnumerator corout2()
{
while (true)
{
yield return new WaitForSeconds(3);
{
gameObject.GetComponent<Renderer>().material.color = Color.blue;
coll.enabled = true;
}
}
}
}
Answer the question
In order to leave comments, you need to log in
What .... What kind of nonsense is this, you asked a question an hour ago, maybe we will already think with our heads and teach Unty how to ask questions that are not clear to you, not to us. Answer - Learn Unity
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question