what's wrong in this script?

i want made a trigger with 2 targets. in target 1: obj1 (column): in target 2: obj2 (unlockable key). When obj1 collide with trigger: activate obj2.

i have this in .js:

var obj1 : GameObject;
var obj2 : GameObject;

function OnTriggerEnter (obj1.Col:Collider)
{
obj2.SetActive(true);
}

You shouldn’t use “obj1.Col”, try with "function OnTriggerEnter (Col:Collider) " instead.

but i want the trigger only collide with target 1 (obj1) not with the player or other objects. how can i do this, without tags?

Well, you certainly can’t do it that way :slight_smile:

Something like this should work:

var obj1 : GameObject;
var obj2 : GameObject;

function OnTriggerEnter (Col:Collider)
{
  if(Col.gameObject == obj1) {
   obj2.SetActive(true);
  }
}

yujuu
a lot of thanks, you save my life