Collision not working

I have a small project, I have a spawnpoint in a moving 2D level. When the level is being geenreated the spawnpoint spawns one of 2 Barriers. These barriers then get attached to the invisble spawnpoint as child object. This was done since the level is moving and the spawnpoint is part of a prefab which is moving. Now the Barriers are also moving exactly like the sapwnpoint. So far so good.

The Script fot this is:

var objs : GameObject;

var SpawnPoint : Transform;

function Start () {

//Spawn Random Barrier at Spawnpoint
var newObj = Instantiate(objs[(Random.Range(0, objs.Length))], SpawnPoint.position, Quaternion.identity);

// Make Barrier a Child of Spawnpoint so it moves with the Level
newObj.transform.parent = SpawnPoint;

}

My Problem now is that I want the player to colide with these Barriers and if he is in the wrong state, he should die. The script for that is:

// collide with barrier and die

function OnTriggerEnter (collisionInfo : Collider) {

if (collisionInfo.gameObject.tag == “BarrierBlue”){

Destroy(gameObject);

}

}

I did not implement the States yet since it is already a problem. The collision for the Barrier does not work. The Box Collider on the Barrier is set to Trigger and the Tag also fits. To be on the save side I even made the barrier 50 pixel wide on the Z Axis to make sure the character does not pass it without hitting it however the collision does no trigger…

Could there be a problem if I attach an object with collision to a different object as child ?

1.) Make sure your tag is actually spelt ‘BarrierBlue’ i.e case sensitive

2.) Check the barrier has the correct tag assigned

3.) Also check you have attached the player script to your player object with the collider.

4.) Don’t make your collider on your player a trigger, only make the collider on your barrier a trigger.

If all those are in place there is no reason why OnTriggerEnter won’t work.