im trying to make a win condition for my game and i want the character to pickup an object then move somewhere else and when they enter a collider it move to the win screen but it keeps giving me errors. should it be 2 diffrent scripts or can i do it in just one?
using UnityEngine;
using System.Collections;
using UnityEngine.SceneManagement;
public class Quest : MonoBehaviour
{
[SerializeField]
bool showObjective = false;
[SerializeField]
Texture objective;
[SerializeField]
private int collision;
public Collider Elevator;
void Start()
{
showObjective = false;
}
void OnTriggerEnter(Collider other)
{
if (other.gameObject.tag == "Player" && collision == 0)
showObjective = true;
}
void OnTriggerExit(Collider other)
{
if (other.gameObject.tag == "Player")
showObjective = false;
collision = 1;
}
void OnGUI()
{
if (showObjective == true)
GUI.DrawTexture(new Rect(Screen.width / 1.8f, Screen.height / 1.4f, 178, 178), objective);
}
void OnTriggerEnter(Collider Elevator)
{
if (Elevator.gameObject.tag == "player" && collision == 1)
SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex + 1);
}
void Update()
{
if (Input.GetButton("Submit") && collision == 1)
{
showObjective = true;
}
if (Input.GetButtonUp("Submit") && collision == 1)
{
showObjective = false;
}
}
}