- Home /
Exit not working properly
I am trying to do it where after you collect an item then going to a spot brings you to level 2. It doesn't with this:
using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.SceneManagement;
public class ExitToLevel2 : MonoBehaviour {
int itemcollected;
void OnTriggerEnter2D(Collider2D col) { if (ItemCollected.itemcollected >= 1 && col.CompareTag ("Player")) { Destroy(col.gameObject); SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex + 1);
}
} }
And it only works when I remove this from the if statement: ItemCollected.itemcollected >=1
Answer by Carterryan1990 · Jul 27, 2018 at 01:11 AM
You should paste your code using the code sample option(ctrl+k) so its more readable.
Your answer
Follow this Question
Related Questions
Help setting up a game manager 1 Answer
Camera to move when i move to the next room 1 Answer
Tilemaps - Create Multiple Levels 0 Answers
Reusing same 2D Environment in different levels 0 Answers
Is it bad to Import a Level from 3DS Max into Unity? 2 Answers