Unable to add neighbors Element in Gem Script

Hi, and thanks in advance for reading this. I’m unable to add neighbors Element in Gem Script. Match 3 Tutorial. 3:20 minutes into video my problem begins. I’ve started this over about 3-5 times now from scratch.

Feelers


using UnityEngine;
using System.Collections;
public class Feeler : MonoBehaviour
{
public Gem owner;

void OnTriggerEnter(Collider c)
{
if(c.tag ==“Gem”)
{
owner.AddNeighbor(c.GetComponent());
}
}
void OnTriggerExit(Collider c)
{
if(c.tag ==“Gem”)
{
owner.AddNeighbor(c.GetComponent());
}
}
}


Gem


using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public class Gem : MonoBehaviour
{
public GameObject sphere;
string[ ] gemMats = {“Red”,“Blue”,“Green”,“Orange”,“Yellow”,“Black”,“Purple”};
string color=“”;
public List Neighbors = new List();
// Use this for initialization
void Start ()
{
CreateGem();
}

// Update is called once per frame
void Update ()
{
}
public void CreateGem()
{
color = gemMats[Random.Range(0,gemMats.Length)];
Material m = Resources.Load(“Material/”+color) as Material;
Renderer renderer = sphere.GetComponent();
renderer.material = m;

}
public void AddNeighbor(Gem g)
{
if(Neighbors.Contains(g))
Neighbors.Add(g);
}
public void RemoveNeighbor(Gem g)
{
Neighbors.Remove(g);
}
void OnMouseDown()
{
}
}


Board


using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public class Board : MonoBehaviour
{
public List gems = new List();
public int GridWidth;
public int GridHeight;
public GameObject gemPrefab;
// Use this for initialization
void Start()
{
for(int y=0;y<GridHeight;y++)
{
for(int x=0;x<GridWidth;x++)
{
GameObject g = Instantiate(gemPrefab,new Vector3(x,y,0),Quaternion.identity)as GameObject;
g.transform.parent = gameObject.transform;
gems.Add(g.GetComponent());
}
}
gameObject.transform.position = new Vector3(-2.5f,-2f,0);
}

// Update is called once per frame
void Update() {
}
}

Thanks in advance,

Melvin

You need to put your code in between the code tags, not after.

Your problem could be this function:

public void AddNeighbor(Gem g)
{
    if(Neighbors.Contains(g))
        Neighbors.Add(g);
}

You tell it to only add g to neighbors if neighbors already contains g. You should probably have a ! in front if Neighbors.Contains(g).