i am making an image viewer type thing and i got key controls working but i wanted to add a way to drag the view with the mouse. how do i register that and apply it.
Are you implementing the viewer with the GUI system or with the image on a plane in the scene?
planes in scene.
here is my camera script
function FixedUpdate () {
transform.Translate((Input.GetAxis("Horizontal")/10)*(transform.position.z/10), (Input.GetAxis("Vertical")/10)*(transform.position.z/10), Input.GetAxis("Zoom")/10);
transform.position.z = Mathf.Clamp(transform.position.z,0.5,100.0);
}
One way to go might be to add a configurable joint to the image plane and set its Z motion and all rotation axes to Locked (and also turn gravity off for the rigidbody). Then, you can drag the object using the Drag Rigidbody script supplied with Unity on the Scripts menu. Another approach is to use a raycast to detect the location where the mouse hit the plane each frame (see this thread for details and some code). You just need to subtract the position of the raycast hit point on the current frame from that of the previous frame. This gives you a movement vector. You then just need to pass this vector to transform.Translate on the plane.
well actualy the images dont move at all. it is the camera that moves but i will look at the suggestions that you gave me.