Hi everyone, I create 3 main Game Objects with child objects.
ObjectA–> add a Game Object (name"cat"), then add a empty Game Object with Box Collider (name"boxA"), mark with “isTrigger”, and assigned script (OnTriggerEnter.cs).
ObjectB → add a empty Game Object with Box Collider (name"boxB") and a rigidbody.
ObjectC → add a empty Game Object with Box Collider (name"boxC")and a rigidbody.
In OnTriggerEnter.cs, I sucessfully write a script (see Code Try1) that when boxA collide with boxB, a CAT shown.
However, when I change to code to become the code like Code Try2, a CAT do not shown. Why?
I am trying to show a CAT when both boxB and boxC collide with boxA at the same time.
I am stuck at here two days ago… Please help. Thanks in advanced.
Code Try1:
public void OnTriggerEnter(Collider other){
if(other.gameObject.collider.name == "boxB")
{
mCat.SetActive(true);
}}
Code Try2:
public void OnTriggerEnter(Collider other){
if(other.gameObject.collider.name == "boxB" && other.gameObject.collider.name == "boxC")
{
mCat.SetActive(true);
}}