locking axes for transform.lookat ?

I have a 2.5d game where all my objects are at 0 on the z. Attached to my main camera I have a plane textured transparently with an arrow pointing up in it’s starting rotation. I want to rotate it around the z to point at various things. I need to lock rotation on the the x and y, having it rotate around the z. I’ve tried using transform.lookat and quaternion.lookrotation but I can’t get it to work the way I want it to.

You should create a logical plane at the arrow position and perpendicular to the camera. Create also a ray pointing at the desired world object and use Plane.Raycast and Ray.GetPoint to find the point where the ray hits the logical plane. Finally, if the arrow is aligned to its Z axis, use LookAt to rotate the arrow plane so that it points at the target object.

The whole thing can be implemented in a script attached to the arrow plane - call the function PointAt passing the transform of the world object you want to point at:

function PointAt(target: Transform){
  // arrow axis:
  var axis = -Camera.main.transform.forward;
  // create a plane at the arrow position:
  var plane = new Plane(axis, transform.position);
  // create a ray pointing at the target object:
  var camPos = Camera.main.transform.position;
  var ray = new Ray(camPos, target.position - camPos);
  var distance: float;
  if (plane.Raycast(ray, distance)){
    // find the point hit by the ray:
    var tgPoint = ray.GetPoint(distance);
    // rotate arrow plane about the axis to point at the target:
    transform.LookAt(tgPoint, axis);
  }
}