I want to add a snap option to two parent objects with their childs.
The collison is 2D with trigger.
Non-collided state is as belows:
After collison, i change the color of the part to green with:
void OnTriggerEnter2D(Collider2D other)
{
if (other.gameObject.tag == "Board")
{
other.GetComponent<Renderer>().material.color = Color.white;
GetComponent<Renderer>().material.color = Color.green;
}
}
Then the state becomes as belows:
What I want to do is,if every part is green, on double click, keypres or whatever, I want to change all collided childs position to other collided objects position ( snap )
I can check the situation if everypart is green with :
foreach (Renderer r in GetComponentsInChildren<Renderer>())
{
if (r.material.color != Color.green)
{
//do action
}
The point I am stuck is to check the collision state of each component and equalize them to collided parts.
I would appreciate your help on the subject.
Thank you.