Hello,

Consider me a total noob in C#. Im currently doing an Internship, and I’ve never used Unity or learned C#, and my time is running short ( I have until day 28 of this month, aka tomorrow ) . The game is an Infinite scroller, flappy bird style, and im trying to create an upgrade that slows time on collision, waits some seconds, and returns to normal ( Im doing this by using timescale ).
Basicaly the erroris: yield is not working, its not waiting and executing the next command, why?

This is the script:

using UnityEngine;
using UnityEngine.UI;
using System.Collections;

public class SlowMo : MonoBehaviour {

void OnTriggerEnter2D(Collider2D co) {
	if (co.name == "goldy" || co.name == "yellowFish") {
		StartCoroutine (Tempo ());
	}
}
IEnumerator Tempo (){
	Time.timeScale = 0.5f;
	yield return new WaitForSeconds (2.0f);
	Time.timeScale = 1.0f;
	Debug.Log ("askjgdnwlefd");
}

}

As you can see, im using a Debug.Log in the end to see if the command is actually executed, which is not.

Its probably a small error, but I cant figure this out… Would appreciate some help here!

I found my problem.

Apparently my script to destroy objects when they got out of my camera were destroying my powerup object before he could finish its commands. I changed the time it took to destroy the game objects to 6 seconds and my problem was solved.

Hope it helps other around here!

Happy coding,

Drakegui