Hey guys, so I have an endgame trigger and a next level button function. As soon as I start the level, the level completes straight away, even though my player is no where near the endgame trigger box collider.
Here are my scripts to show how everything has been setup:
GameFinishTrigger (with trigger collider)
using UnityEngine;
public class GameFinishTrigger : MonoBehaviour {
public EndGame gameManager;
public void OnTriggerEnter(Collider other)
{
gameManager.CompleteLevel();
}
}
My Game Manager script
using UnityEngine;
using UnityEngine.SceneManagement;
public class EndGame : MonoBehaviour {
bool endGame = false;
public GameObject completelevelUI;
public GameObject youDied;
public void CompleteLevel ()
{
Debug.Log("level won");
completelevelUI.SetActive(true);
}
public void gameover ()
{
if (endGame == false)
{
endGame = true;
youDied.SetActive(true);
}
}
}
Any ideas why my game is completing the level straight away, despite my player being nowhere near the trigger? This setup is (as far as I can see) Identical to another level I’ve done and this has not been a problem there.
Any help is appreciated!
Thanks ![]()