Help needed concerning rotation of gameObject in grid

Hello there,

i am currently working on a city builder game which is grid based. I managed to create the building placement, i added a feature that a taller building needs to grid placements and gets placed in the middel of both.
But now, i am stuck cncering the rotation. I want that if a grid pattern with a higher x and z value is chosen, the building is rotated by 90 degrees, if only the x OR the y value are smaller/higher, the builing should not have any y rotation. I tried it severeal times, but i didnt get any solution. I put some pictures down here!

Thank you very much!

Fabian



Already found a solution!

Hi, nice that you could find a solution by your own. I think it would be nice, if you would post the solution here, if possible. Maybe anyone else runs into the same problem in the future