Struggling with array list :(

Im new to scripting so this is kinda newbie question :smile: Why is the if statement in the Update() not working?!? i know the arraylist is working because i can see it changing in the editor. :frowning:

using UnityEngine;
using System.Collections;
using System.Collections.Generic;

public class BlockCollider : MonoBehaviour {

	public List<Collider> colliders = new List<Collider>();
	public Collider LeftSnap;

	void Update()
	{
		if(colliders.Contains(LeftSnap)) /// THIS IF STATEMENT JUST DOESNT WORK :(
		{
			Debug.Log ("THIS IS THE LEFT");
		}
	}

	void OnTriggerEnter(Collider c)
	{
		if(c.tag == "LeftSnap" || c.tag == "RightSnap")
		{
			colliders.Add(c);
			
		}
	}
	
	void OnTriggerExit(Collider c)
	{
		if(c.tag == "LeftSnap" || c.tag == "RightSnap")
		{
			colliders.Remove(c);
		}
	}
}

‘LeftSnap’ is a empty gameObject with a box collider as a trigger attached

EDIT THIS IS FIXED :slight_smile:

Any help appricated :slight_smile:

It isn’t working because you have a list of Colliders.

And then when you are checking the Trigger, you say I want to only
accept colliders with the tag of LeftSnap or RightSnap.

But in your if statement you are saying that among your colliders
you are looking for LeftSnap.

But thats the tag name. So you won’t
find it unless you say you are looking for the collider.tag with the name of LeftSnap

Hope this helps. Just have to make sure you let the computer know exactly what you are
looking for in the list. Does my list contain any colliders with the tag name of LeftSnap