- Home /
Handling two triggering objects at the same time
Hello everyone,
I want to know if its possible to work with two objects that are triggering a third object at the same time. I have one cube in between 2 cubes, all have triggers on them so I want the cube in the middle to be able to modify each of the cubes seperately. This is the code I have:
void OnTriggerStay2D(Collider2D trigger)
{
if (BesideL == true)
{
left = trigger.gameObject;
}
if (besideR == true)
{
right = trigger.gameObject;
}
Ok, BesideL and BesideR are two boolean variables that work with two separate raycasts to tell me if there are cubes on the left or right sides. right and left are two gameobject variables I want to assign the cubes to. I tried this and it does not work, whatever cube it collides with first, it puts that in both the right and left gameobjects.
thanks for the help
Comment