Hello everyone first time asking a question but I seem to be having some trouble with trying to get this dam camera to work on unity basically im making an RTS game (in my free time and when im due back to college) and im trying to code the camera so that when your mouse goes near or on the edge of the screen the camera moves like in most if not all RTS based games.
Here is my code I have tried some methods of solving and have managed to bring my errors down to one but obviously the game won’t run due to these errors.
here is the code in letters if you can’t see the image.
public class CameraMovement : MonoBehaviour {
#pragma strict
var edgeBoundary ; int = 10;
function Update () {
if(Input.mousePosition.y < Screen.height/edgeBoundary || Input.GetButton("Vertical") && Input.GetAxis("Vertical") < 0){ // Mouse is at bottom of screen
transform.position += Vector3(0,0,-0.1);
}
if(Input.mousePosition.y > Screen.height - Screen.height/edgeBoundary || Input.GetButton("Vertical") && Input.GetAxis("Vertical") > 0){ // Mouse is at top of screen
transform.position += Vector3(0,0,0.1);
}
if(Input.mousePosition.x < Screen.width/edgeBoundary || Input.GetButton ("Horizontal") && Input.GetAxis("Horizontal") < 0){ // Mouse is at left of screen
transform.position += Vector3(-0.1,0,0);
}
if (Input.mousePosition.x > Screen.width - Screen.width / edgeBoundary || Input.GetButton ("Horizontal") && Input.GetAxis ("Horizontal") > 0) { // Mouse is at right of screen
transform.position += Vector3 (0.1, 0, 0);
}
}
}