Question by
bharath09vadde · Dec 27, 2017 at 11:27 AM ·
vuforiawaitforsecondstrailrenderer
Problem with wait for seconds when my game is paused.
I am creating an app where my trail renderer of one sphere has to be activated when going in forward direction and while returning it has to be stopped and second sphere trail renderer has to be activated and its in a loop. So I have used wait for seconds to activate and deactivate(Iam not good at scripting). My game have a play and pause buttons. When I paused my game and play it after some time then everything is overlapped since I have used wait for seconds. Can somebody tell me some other way to do it other than wait for seconds. Here is my code.
{
private TrailRenderer tr;
float n = 6.5f;
void Start()
{
tr = GetComponent<TrailRenderer>();
tr.material = new Material(Shader.Find("Sprites/Default"));
StartCoroutine(Fadeaway());
StartCoroutine(nofade());
}
IEnumerator Fadeaway()
{
for (int i = 0; i < 10000; i++)
{
yield return new WaitForSeconds(n * (2 * i));
tr.time = 0;
}
}
IEnumerator nofade()
{
for (int i = 0; i < 10000; i++)
{
yield return new WaitForSeconds(n * (2 * i + 1));
tr.time = 1.5f;
}
}
}
Comment