Okay I’m having a really big problem with this. I’ve been trying to pause the game when either a function is enabled, a collision with a certain gameobject happens, or when whenever. By the way I don’t mean pause the game when all of these things happen, I mean I tried them all but it doesn’t work for me. I just want to pause the game when I collect a power up, and wait for 3 seconds then un-pause the game. Time.timeScale never ever works for me by the way.
Look at this function:
public void SpeedUp()
{
Debug.Log( "SpeedUp()" );
Time.timeScale = 0;
}
This is the beginning of the function as you can probably tell. I tried doing this and similar things but it won’t pause anything.
I also tried stopping time by collision, but I was told this wasn’t going to work because the gameObject I’m colliding with destroys itself therefore destroying the Time.timeScale = 0;, which means it never happens. Here it is anyways if anyone knows how to fix this:
public class PowerupScript : MonoBehaviour {
void OnTriggerEnter2D(Collider2D other)
{
if (other.tag == "Player") {
ControllerScript playerScript = other.gameObject.GetComponent<ControllerScript> ();
if (playerScript) {
Time.timeScale = 0;
// We speed up the player and then tell to stop after a few seconds
playerScript.SpeedUp();
}
Destroy (gameObject);
}
}
}
I’m asking/begging you guys/gals. Please help.