I'm new to programming and unity and it keeps replaying this error code CS0236, for reference this is my code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class Safe_Zone : MonoBehaviour
{
public float limitTime;
float unsafeTime = limitTime;
bool reached;
void Update () {
if (reached) { unsafeTime = limitTime; }
else { unsafeTime -= Time.deltaTime; }
if (unsafeTime <= 0f) {
void OnTriggerEnter(Collider other)
{
SceneManager.LoadScene(1);
}
}
}//Do something like destroy the player or show the gameover text, ...
void OnTriggerEnter2D (Collider2D other) {
if (other.gameObject.tag == "Player") { reached = true; }
}
void OnTriggerExit2D (Collider2D other) {
if (other.gameObject.tag == "Player") { reached = false; }
}
}
I'm trying to make where every ten seconds the player is transported into the game over scene, unless he is in a safe zone, I'm out of ideas to solve this.
↧