Finding distance on a local axis

I need to be able to find the distance between two empties both of which are children of the same gameobject along one axis. however the object is constantly rotating so using worldspace calculations are out. also it needs to be only measured on the one axis sovector3.distance is also out, I just don’t know how to get single axis distance on a local axis. any help would be greatly appriciated

solved it using inverseTransformPoint.

controllerDistance = Mathf.Abs(transform.InverseTransformPoint(controllerPos.position).z - transform.InverseTransformPoint(originPos.position).z)