Hi guys,
I making a 3d tower defense game… and its not looking good if I using just one static camera,… can I get any ideas or tutorial … ty
Move the camera? What do you want to do?
Hmm… not sure whats the best… but I think something like simcity camera… so I can move it by clicking on terranin and pull,… or make 4 cameras in the corners?? Dont know.,… What is the name of that camera style? So I can read about that?
For which is best, it depends on the game.
I made a quick drag-able camera for testing a couple of weeks back, although it was for an 2d camera, I added code for a 3d one as well, but I haven’t tested it. It’s a good starting point, but you’ll have to edit it for your needs.
here’s the code:
Camera editorCam;
void zoom() {
float scroll = Input.GetAxis("Mouse ScrollWheel");
editorCam.orthographicSize += -scroll * 10;
//2D
editorCam.orthographicSize = Mathf.Clamp(editorCam.orthographicSize + (-scroll * 10), 1, 20);
//For 3D, untested
//editorCam.orthographicSize = Mathf.Clamp(editorCam.fieldOfView+ (-scroll * 10), 1, 20);
}
void pan() {
if (Input.GetButton("Pan")) {
//2D
this.transform.position += new Vector3(-Input.GetAxis("Mouse X"), -Input.GetAxis("Mouse Y"), 0);
//For 3D, untested
//this.transform.position += new Vector3(-Input.GetAxis("Mouse X"), 0, -Input.GetAxis("Mouse Y"));
}
}