I’m trying to make a black ball become diable/ activate when you press ‘e’ on it’s light.
but it won’t disable at all, nor really come back.
here’s what it looks like
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class light : MonoBehaviour
{
public GameObject darkness;
public bool objactiveon = false;
bool enter = false;
void start(){
}
//diappear the darkness
void Update(){
if (Input.GetKey("e") && enter ){
Debug.Log("This is a log message.");
darkness.SetActive(false);}
}
// check if playes in the box
void OnTriggerEnter(Collider hit){
if (hit.CompareTag("Player")){
Debug.Log("This is a log message.");
enter = true;
}}
void OnTriggerExit(Collider hit){
if (hit.CompareTag("Player")){
Debug.Log("This is a log message.");
enter = false;
}
}
}
here’s the code for it
pls give advice