Hello, when i try to play my 3D Point And Click game, all the colliders on my every object (Nodes) in the scene are disabled. I had this problem after i tried to make a door, that you can open and close with a key. Making that door somehow disabled all colliders, even after i deleted all the door scripts. Link for the tutorial i tried to use to make my door with:
I also get an error every time i to try play the game. Error in Unity:
NullReferenceException: Object reference not set to an instance of an object
Node.SetReachableNodes (Boolean set) (at Assets/Scripts/Nodes/Node.cs:51)
Node.Arrive () (at Assets/Scripts/Nodes/Node.cs:40)
GameManager.Start () (at Assets/Scripts/GameManager.cs:27).
My Node script:
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using DG.Tweening;
public abstract class Node : MonoBehaviour {
public Transform cameraPosition;
public List<Node> reachableNodes = new List<Node>();
[HideInInspector]
public Collider col;
// Use this for initialization
void Awake () {
col = GetComponent<Collider>();
col.enabled = false;
}
void OnMouseDown() {
Arrive ();
}
public virtual void Arrive(){
//leave existing current node
if (GameManager.ins.currentNode != null)
GameManager.ins.currentNode.Leave ();
//set currentNode
GameManager.ins.currentNode = this;
//move the camera
GameManager.ins.rig.AlignTo(cameraPosition);
//turn off our own collider
if (col != null)
col.enabled = false;
//turn on all reachable node's colliders
SetReachableNodes(true);
}
public virtual void Leave(){
//turn off all reachable node's colliders
SetReachableNodes(false);
}
public void SetReachableNodes(bool set){
foreach (Node node in reachableNodes){
if (node.col != null) {
if (node.GetComponent<Prerequisite> () && node.GetComponent<Prerequisite> ().nodeAccess) {
if (node.GetComponent<Prerequisite> ().Complete) {
node.col.enabled = set;
}
} else {
node.col.enabled = set;
}
}
}
}
}
GameManager Script:
using UnityEngine;
using System.Collections;
public class GameManager : MonoBehaviour {
public static GameManager ins;
public IVCanvas ivCanvas;
public ObsCamera obsCamera;
public InventoryDisplay invDisp;
public Node startingNode;
[HideInInspector]
public Node currentNode;
public Item itemHeld;
public CameraRig rig;
//singleton
void Awake() {
ins = this;
ivCanvas.gameObject.SetActive(false);
obsCamera.gameObject.SetActive (false);
}
void Start(){
startingNode.Arrive ();
}
void Update() {
if (Input.GetMouseButtonDown(1) && currentNode.GetComponent<Prop>() != null){
if (ivCanvas.gameObject.activeInHierarchy) {
ivCanvas.Close();
return;
}
if (obsCamera.gameObject.activeInHierarchy) {
obsCamera.Close();
return;
}
currentNode.GetComponent<Prop>().loc.Arrive();
}
}
}