so i have this script
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class bomb_checker : MonoBehaviour
{
public bool nearbomb;
public void OnCollisionEnter(Collision other)
{
if(other.gameObject.CompareTag("Bomb"))
{
nearbomb = true;
}
}
public void OnCollisionExit(Collision other)
{
if (other.gameObject.CompareTag("Bomb"))
{
nearbomb = false;
}
}
}
and i am trying to refrence nearbomb in this script
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class cam_switch : MonoBehaviour
{
public GameObject Player;
public GameObject BombCam;
bomb_checker Bomb;
void Start()
{
Player.SetActive(true);
BombCam.SetActive(false);
Bomb = GameObject.Find("nearbomb").GetComponent<bomb_checker>();
}
void Update()
{
if(Input.GetKeyDown(KeyCode.E) && Bomb.nearbomb == true)
{
Player.SetActive(false);
BombCam.SetActive(true);
}
if (Input.GetButtonDown("Fire2"))
{
Player.SetActive(true);
BombCam.SetActive(false);
}
}
}
but when i do this is giving me the error NullReferenceException: Object reference not set to an instance of an object not sure what i did wrong