I have a script, where on CollisionEnter2D the particles are emitted from an object and the game pauses. The particles stop too. But I don't want to pause the particles. I want them to play even when the game is paused. How can I do this?
Here is a script:
using UnityEngine;
public class MovingPlayer : MonoBehaviour
{
public float playerSpeed;
public float maxPos = 2.7f;
Vector3 position;
public uiManager ui;
Rigidbody2D rb;
public GameObject particleSystemPrefab;
void Awake ()
{
rb = GetComponent<Rigidbody2D>();
}
// Use this for initialization
void Start ()
{
position = transform.position;
}
......
void OnCollisionEnter2D (Collision2D col)
{
if (col.gameObject.tag == "CubeObstacle") {
foreach(ContactPoint2D contact in col.contacts)
{
Instantiate(particleSystemPrefab, contact.point, Quaternion.identity);
}
Time.timeScale = 0;
ui.gameOverActivated();
am.playerSound.Stop();
PlayerPrefs.SetInt("score", score);
PlayerPrefs.Save();
}
}
}
