Hello, I want to know how can I pause the game(or the Player) right when I grab a power up, and then un-pause it after 3 seconds or so. I can't even get it to pause at all, even when i use Time.timeScale, or am I using it wrong? Please let me know. I've paused the game before, but that was when i pressed a GUI button for a pause menu. So it's different. Here's the script I'm trying to work with(it's the power up script): Code (CSharp): public GameObject coinEffect; void OnTriggerEnter2D(Collider2D other) { if (other.tag == "Player") { Time.timeScale = 0f; ControllerScript playerScript = other.gameObject.GetComponent<ControllerScript> (); // not sure about the syntax here... if (playerScript) { playerScript.SetInvincible (); playerScript.SpeedUp(); } GameObject effect = Instantiate(coinEffect, transform.position, transform.rotation) as GameObject; Destroy(effect.gameObject, 3); Destroy (gameObject); } } }
From what I see, you're destroying the gameobject to which the script is attached to? This will cause all the components of the gameobject to be destroyed including the scripts.