Rotate geometry based on height

I have a gird of hexagons that i wish to rotate depending on their Z position. Lets say the boundary of rotaion angle is 0 to 45 degrees, and the higher the panel is the more it will rotate. Panels with the lowest Z with have no rotation and panels with the highest z will have 45 degrees of rotation. Preferibly in the z rototional direction as well. At the moment I can only make them all rotate in one angle around the xy plane. What whould be the most effecient way of doing this?

hexagon grid (11.6 KB)

Like this?

hexagon grid (10.9 KB)


yes, thank you:)