camera transform relative to another transform

I’ve got a camera system that has both follow (by default) and middle-mouse-click orbit. If the middle mouse button is released, the camera snaps back to the follow camera.

The follow camera rotates x,y and z of the target.

What I’m finding is that in the orbit script, I’m having a hard time calculating X,Y based off the mouse axis changes relative to z != 0.

What’s the best way in unity3d to transform relative to the follow camera (and thus the actual target)? Are there helper functions for this, or should I do the transforms manually?

Thanks!
–strtok

I think the easiest way to find transform A coordinates relative to transform B is to set transform A’s parent equal to B and then look at the local coordinates of transform A. After that you can restore the original parent of A.

This was solved by multiplying the two vectors (or quaternions).