I am looking for a script that with the orthographic camera on LeftMouseButton Down + MouseMove Left, Right, up down. Camera.main.position X-- / X++ or y-- /y++.
Just think of the movement in google maps or other map packages.
I am looking for a script that with the orthographic camera on LeftMouseButton Down + MouseMove Left, Right, up down. Camera.main.position X-- / X++ or y-- /y++.
Just think of the movement in google maps or other map packages.
Input.mousePosition: tells you where the mouse is in screen coordinates. Each Update(), compare mousePosition to the last stored value to calculate a delta; apply the delta (scaled appropriately) to your camera position; and update the stored value.
I think you can use:
Input.GetAxis (“Mouse X”) > 0
Input.GetAxis (“Mouse X”) < 0
Input.GetAxis (“Mouse Y”) > 0
Input.GetAxis (“Mouse Y”) < 0
But you need to take care of the acceleration
Okay thanks guys. Now the camera translation / position function is camera.main.Transform.position(x,y,z)? the scripting reference gives information that the camera is in the typical x,y,z placement but doesn’t give any examples of a camera position transform.
If I wanted to add the Left Mouse button with mouse movement I am guessing one section of the script would be:
if(Input.GetMouseButtonDown(0))
{
if ( (Input.GetAxis(“Mouse X”)>0) )
{
Debug.Log(“Pressed left click and moved mouse X”);
//not sure how to transform position of camera.
camera.transform.position = new Vector3 (increment a float X somehow somewhere?,y,z)
}
}
How about (untested):
if (Input.GetMouseButton(0)) {
camera.transform.position += camera.transform.right * Input.GetAxis("Mouse X") * sensitivityX;
camera.transform.position += camera.transform.up * Input.GetAxis("Mouse Y") sensitivityY;
}
The point is, you need to transform mouse motion into world-space motion, not just apply it axially.
Laurie your a genius. Thanks!