Moving camera around with GUI buttons

Howdy all,

I have a VERY simple GUI that moves my main camera through my scene. It functions by having a camera that is a child of a sphere in the scene. The sphere is caused to rotate by the GUI and the camera then moves, focused on the sphere. This is in no way ideal, but I am a a short time frame and its the best a beginner can come up with. I am wondering now, how would I add a zoom function to the following GUI:

Code:

var imageLeft: Texture2D;
var imageRight: Texture2D;
var imageUp: Texture2D;
var imageDown: Texture2D;
var speed: float = 60;
private var rotLeft = false;
private var rotRight = false;
private var rotUp = false;
private var rotDown = false;
var w1:float;
var x1:float;
var y1:float;
var z1:float;
var w2:float;
var x2:float;
var y2:float;
var z2:float;
var w3:float;
var x3:float;
var y3:float;
var z3:float;
var w4:float;
var x4:float;
var y4:float;
var z4:float;
 
 
function OnGUI(){
rotLeft = GUI.RepeatButton(Rect(w1,x1,y1,z1),

imageLeft);
rotRight = GUI.RepeatButton(Rect(w2,x2,y2,z2),
imageRight);
rotUp = GUI.RepeatButton(Rect(w3,x3,y3,z3),
imageUp);
rotDown = GUI.RepeatButton(Rect(w4,x4,y4,z4),
imageDown);
}

function Update(){    
 
if (rotLeft) transform.Rotate(0, -speed*Time.deltaTime, 0);
if (rotRight) transform.Rotate(0, speed*Time.deltaTime, 0);
if (rotDown) transform.Rotate(0, 0, speed*Time.deltaTime);
if (rotUp) transform.Rotate(0, 0, -speed*Time.deltaTime);
}

Or if anyone has any other suggestions for a GUI based controller I would be glad to hear them. The idea though is that the camera will orbit an object and constantly be looking at it. The only reason there are so many variables for the positioning of the buttons is aesthetics. I like to be able to move things around to see where they look best.

Thanks a ton,
Richard

I beleave another if statement with something down the Z axis would be neededusing the transform.position.z(or the X) and then just set up by how much .5 perclick or on a repeat button like you have.

Thanks for responding. Yeah, I’m trying to make it smooth. But so far I have only been able to make it move very jittery and jumpy.
Not really adept at writing code as you can see.

Thanks, HomeSpun. Will do. And when I get this figured out I will post the full code here.

Thanks, HomeSpun. Will do. And when I get this figured out I will post the full code here.