Hi, Im trying to create RTS camera control, but having some problem.
http://netsoccer.eu/testing/WebPlayer.html
When mouse cursor is left or right of screen, camera moves correctly, but when cursor is top or bottom of screen, it zooms.
How this could be solved?
Here is my code
void Update () {
//Move camera when cursor on edge of screen.
if(Input.mousePosition.x > Screen.width - 10){ //works ok
transform.Translate(new Vector3(1,0,0) * Time.deltaTime * cameraSpeed, Space.Self);
}
if(Input.mousePosition.x < 10){ //works ok
transform.Translate(new Vector3(-1,0,0) * Time.deltaTime * cameraSpeed, Space.Self);
}
if(Input.mousePosition.y > Screen.height - 10){ //doesnt work, as wanted
transform.Translate(new Vector3(0,0,1) * Time.deltaTime * cameraSpeed, Space.Self);
}
if(Input.mousePosition.y < 10){ //doesnt work, as wanted
transform.Translate(new Vector3(0,0,-1) * Time.deltaTime * cameraSpeed, Space.Self);
}
}