Well, The title says it all.
1 Answer
1Well, you could do something like this-
Put a big trigger volume on the object, and then make a script for counting the number of enemies in the scene-
float heightProportion = 1;
public Vector3 someHighPlace;
public Vector3 someLowPlace;
Update()
{
if(GameObject.FindGameObjectsWithTag ("Enemies").Length == 0)
{
heightProportion = Mathf.Clamp01(heightProportion - Time.deltaTime);
}
transform.position = Vector3.Lerp(someLowPlace, someHighPlace, heightProportion);
}
This will move your object when you run out of things to kill.
Then on your object, do something like this-
OnTriggerEnter(Collider other)
{
if(other.gameObject.tag == "Player")
{
Application.LoadLevel("Next Level");
}
}
This is all strictly psuedocode- while it’ll techincally compile in C#, you’ll have to adapt it to do exactly what you need it to do. Most notably, you need your enemies to all share a tag, and you need your player to have a different tag.
Both of those snippets go into the same script, but in different places. The top one does the moving, the bottom one does the level changing! Both scripts should be on the same gameObject, and that object should have a large trigger collider on it. You can also have some kind of mesh or particle effect on it, if you want it to look like something, or better still, just put all the visuals on a separate object which is a transform child of the trigger object!
– syclamoth
... it shouldn't.
– syclamoth