Hi there
Just wondering if there was a script or something would allow a single camera to be able to zoom, pan and rotate around a scene? Im a newbie so all of this is completely alien to me!!
Thanks
-D-
Hi there
Just wondering if there was a script or something would allow a single camera to be able to zoom, pan and rotate around a scene? Im a newbie so all of this is completely alien to me!!
Thanks
-D-
Don’t know if there’s a script that would perfectly suit your need but the problem you’re describing isn’t too hard to solve. For the zoom you need to modify the FOV of the camera. To pan, if you want to, you could modify the transform of the camera with for example the WASD layout. To rotate you could use mouseinput and manipulate the transform.rotate of the camera.
As an example, to translate (move) your camera upwards you could use the following bit of code:
//This script will control the panning of the camera
//cameraVar
var camera : GameObject;
//Var for controlling which speed the camera will have
var thrustSpeed : int;
function Update () {
if (Input.GetButton("Forward Thrust")){
rigidbody.AddRelativeForce(Vector3.forward * thrustSpeed);
}
if (Input.GetButton("Backward Thrust")){
rigidbody.AddRelativeForce(-Vector3.forward * thrustSpeed);
}
if (Input.GetKey("a")){
rigidbody.AddRelativeForce(Vector3.left * thrustSpeed);
}
if (Input.GetKey("d")){
rigidbody.AddRelativeForce(Vector3.right * thrustSpeed);
}
//Dampen the force
rigidbody.velocity = rigidbody.velocity * 0.95;
}
You need to have a rigidbody attached to the camera or what I prefer, make the camera a child of an empty gameObject that you attach this script to. The gameObject needs to have a rigidbody component attached to it of course.
If you have any questions don’t hesitate to ask.