I have 3 scenes i have created with unity. In my first scene after killing enemies they keep coming and won’t stop. I want to kill few enemies in the first scene “say 10” and second scene “say 20+” and so on. And after killing enemies in first scene, i want to go to the second scene until the last scene.
i need help with this.
thank you
Make a script called “SceneChanger”. Attach it to a game object or whatever.
In that script, put:
public int killLimit; // so you can set this in the inspector for each scene (10, 25, 40 , etc.)
also,
private int totalKills; // keep a running total
So whenever you kill an enemy you call a function in that script, call it, “AddKill()”, where you would increment totalKills.
Then put in the update function:
if (totalKills >= killLimit) Application.LoadLevel(Application.loadedLevel + 1);
using UnityEngine;
public class SceneChanger : MonoBehaviour
{
public int killLimit;
private int totalKills;
public in AddKill()
{
if(totalKills >= killLimit) Application.Loadlevel(Application.loadlevel +1);
}
}
should it be something like this? Do you use C# or Js.