My colliders arent being added to a build script help
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public class PreviewObject : MonoBehaviour
{
public bool foundation;
public List<Collider> col = new List<Collider>();
public Material green;
public Material red;
public bool isBuildable;
void OnTriggerEnter(Collider other)
{
if (other.gameObject.tag == "Buildable" && foundation)
{
col.Add(other);
Debug.Log("AddedCol");
}
Debug.Log("test1");
}
void Update()
{
changecolor();
}
void OnTriggerExit(Collider other)
{
//(other.gameObject.layer == 9 && foundation)
if (other.gameObject.tag == "Buildable" && foundation)
{
col.Remove(other);
}
}
public void changecolor()
{
if (col.Count == 0)
isBuildable = true;
else
isBuildable = false;
if (isBuildable)
foreach (Transform child in this.transform)
{
child.GetComponent<Renderer>().material = green;
}
else
{
foreach (Transform child in this.transform)
{
child.GetComponent<Renderer>().material = red;
}
}
}
}