I use
CircleCollider2D cir;
void Start ()
{
cir = GameObject.FindWithTag("Plant").GetComponent<CircleCollider2D>();
cir.istrigger = true;
}
but it just affect to the 1st CircleCollider2D only.
and I dont know how to use Getcomponents (with s)
If i understood you correctly you want to get 2 objects , with a mouse click, here’s my code , basically i find Gameobject with the name 1 , and then , after i press mouse button i’m getting component circlecollider2d and access to it’s istrigger attribute and set it to true , and right after i did that, script is searching for another one circlecollider2d with the name 1 :
void Start () {
obj = GameObject.Find("1");
}
void Update () {
if( Input.GetMouseButton(1)){
obj.GetComponent<CircleCollider2D>().isTrigger = true;
obj = GameObject.Find("1");
}
}
}