# Track Quaternion local Y axis to position

What do I need is to track Quaternion to some point using it’s local Y axis, how do I think it should work:

``````Quaterion curQua; // Current and result rotation
Vector3 curPos; // Current position
Vector3 tarPos; // Target position
Quaternion tarQua = Quaternion.LookRotation(tarPos-curPos) // Target rotation in global space
Quaternion locQuaDelta = some black magic // Get tarQua in space of curQua
curQua *= Quaternion.Euler(0, locQuaDelta.eulerAngles.y, 0); // Result
``````

How should I solve this problem?

Solved this that way:
Getting target vector, projecting it on object’s local space, getting angle, than rotating object by that angle:

``````transform curTran; // Current transform
Vector3 tarPos; // Target position
Vector3 tarVect = curPos - tarPos; // Target rotation vector (z axis for object)
tarVect = Vector.ProjectOnPlane(tarVect, curTran.up); // Getting projection
float angle = Vector3.angle(curTran.forward, tarVect) // Rotation angle via local Y
if (Vector3.Cross(Transform.forward, targetVector).y < 0) // If vectors have reverse order
angle = -angle; // Set negative angle
curTran.rotation *= Quaternion.Euler(0, angle, 0) // Rotating.
``````

Working for me, maybe there is some simpler way to do this, also, what will I do if I don’t have transform?