How can I detect whenever two of my colliders got hit by the raycast at the same time?
Here is my current code:
for(int i = 0; i < Input.touchCount; i++)
{
Touch touch = Input.GetTouch(i);
Ray ray = camera.ScreenPointToRay(Input.touches*.position);*
-
Physics.Raycast(ray, out hit);*
-
//If A is touched*
-
if(hit.collider.tag == "A")*
-
{*
-
Debug.Log("A");*
-
}*
-
//If B is touched*
-
if(hit.collider.tag == "B")*
-
{*
-
Debug.Log("B");*
-
}*
-
//If A and B is touched at the same time*
-
if(hit.collider.tag == "A" && hit.collider.tag == "B")*
-
{*
-
Debug.Log("C");*
-
}*
-
}*
What I want here to happen is to haveDebug.Log("C");
executed.
But instead the things being executed areDebug.Log("A");
andDebug.Log("B");
I don’t want “A” and “B” executed, I only want “C”.
EDIT: “C” does not get executed. Only A and B.
Is there a simple way I can do this?
Thanks!!