- Home /
hi every 1 new here i have game where every thing is perfectly working but when i finish level 1 it unlocks two levels instead of one please any solution thanks in advance
this is my code private void OnCollisionEnter(Collision collision) { if (collision.gameObject.CompareTag("aii")) { StartCoroutine(fail());
}
}
IEnumerator fail()
{
yield return new WaitForSeconds(4);
int currentlevel = PlayerPrefs.GetInt("Alllevel");
PlayerPrefs.SetInt("unlock", currentlevel);
failpanel.SetActive(true);
}
private void OnTriggerEnter(Collider other)
{
if (other.gameObject.CompareTag("win"))
{
StartCoroutine(win());
player1.gameObject.GetComponent<Rigidbody>().isKinematic = true;
}
}
IEnumerator win()
{
yield return new WaitForSeconds(4);
//int currentlevel = PlayerPrefs.GetInt("Alllevel");
PlayerPrefs.SetInt("Alllevel", PlayerPrefs.GetInt("Alllevel", 0)+1);
PlayerPrefs.SetInt("unlock", currentlevel);
winpanel.SetActive(true);
}
,
Comment
Your answer
Follow this Question
Related Questions
Run Script From Level to Level 1 Answer
Switch Levels After Getting A Score? 2 Answers
How can I get level's bounds (top, bottom, left, right, front, back)? 0 Answers
Large 2D polygon mesh levels 1 Answer