Rotate each mesh of an array by its own coordinates?

Imagine you have a line of columns with an array, and you want each one to rotate 90 degrees on the Z axis, but remain array-ing in a straight line. I have had trouble with this, as using an empty for “object offset” results in the columns instead curving across multiple axes. They rotate by Z, yes, but they also translate across the XY plane. I want them to rotate and maintain the straight line.

Given the nature of object offset, which by definition, offsets the elements, it’s not doable. The objects are not “real”, so don’t have their own origin. I am not sure how you could do this whilst still keeping the array as a modifier, maybe animation nodes, even then, the “local axis / origin” would be an issue I think.

Don’t apply the modifier…
In edit mode, select individual origins…unselect all, then border select the original in x-ray mode, ( all will look selected due to the array ), then rotate z + or - 90…

here is an example to play with…
Column array.blend (4.4 MB)

If all of them are to rotate the same 90 degrees, then you will have to rotate the original object in edit mode, while having the offset in the array modifier set constant rather than relative. Relative offsets from object bounds and creates the sliding that you see, constant maintains a constant offset from the center and will not slide the objects.