Camera panning?

Hey so this is my script

============================================

#pragma strict

var object : GameObject;

function OnGUI () {
//Camera pan left
if (GUI.RepeatButton(Rect(Screen.width/1.25 - (Screen.width/10)/2, Screen.height/15 - (Screen.height/10)/2, Screen.width/4.3, Screen.height/26), "Pan Left")) {
transform.RotateAround(object.transform.position, Vector3.up, 8 * Time.deltaTime);
}

//Camera pan right
if (GUI.RepeatButton(Rect(Screen.width/1.25 - (Screen.width/10)/2, Screen.height/9.5 - (Screen.height/10)/2, Screen.width/4.3, Screen.height/26), "Pan Right")) {
transform.RotateAround(object.transform.position, Vector3.down, 8 * Time.deltaTime);
}

//Camera pan up
if (GUI.RepeatButton(Rect(Screen.width/1.25 - (Screen.width/10)/2, Screen.height/7 - (Screen.height/10)/2, Screen.width/4.3, Screen.height/26), "Pan Up")) {
transform.RotateAround(object.transform.position, Vector3.right, 6 * Time.deltaTime);
}

//Camera pan down
if (GUI.RepeatButton(Rect(Screen.width/1.25 - (Screen.width/10)/2, Screen.height/5.5 - (Screen.height/10)/2, Screen.width/4.3, Screen.height/26), "Pan Down")) {
transform.RotateAround(object.transform.position, Vector3.left, 6 * Time.deltaTime);
}
}

================================================

so it pans left and right fine, but lets say i pan halfway around the object, and then pan up or down, it still rotates around the x axis, so it looks like the map is tilting on its side. Any help?

Oh and I tried making the “object” in this script LookAt the camera, because that would make the x axis always perpendicular to the camera’s LoS, but for some reason I still have the issue.

Guyyyyys heeeeelppppp. I have no idea how to fix this!!!

Is the Pan up. Pan down, rotation around the x axis?! If so, then why doesn’t it pan around the x axis after I change the rotation of the target???

You can make a new blank GameObject (let’s call this the “proxy”) that this script looks at (what is in the object field) and rotates around, and then parent the previous thing it looked at to this new “proxy” object.

When you rotate the actual object, you would NOT be rotating the proxy, but when you go to MOVE the object, you would instead move the proxy.

That makes no sense though. I am parenting an empty target to the original target, andt hen making the camera pan around the parent target, which makes the child target useless? what?!

My issue is that the camera pans around the y axis fine, and the x axis. But when the camera pans 90 degrees around the y axis, the x axis is pointing at the camera, which makes the camera tip side to side instead of pan up/down.

It is as if the targets axes are saved somehow when the scene starts and they don’t ever ACTUALLY change. Because although I can make the z axis always point at the camera, the camera still tips. fuck