- Home /
Camera go ahead according to rotation.
Hi, i need to my camera go ahead according to rotation, like the Unity's editor camera. using UnityEngine; using System.Collections;
public class CameraScript : MonoBehaviour {
private Vector3 translation = new Vector3(-4,2.5f,-4);
private Vector3 rot = new Vector3(30,45,0);
void Update(){
translation += new Vector3(Input.GetAxis ("Horizontal")/10,
Input.GetAxis ("Diagonal")/10,
Input.GetAxis ("Vertical")/10);
transform.position = translation;
if (Input.GetKey (KeyCode.Mouse1))
rot += new Vector3(Input.GetAxis ("Mouse Y")*10,
Input.GetAxis ("Mouse X")*10,
0);
if (Input.GetKey (KeyCode.Mouse2))
translation += new Vector3(Input.GetAxis("Mouse Y") * 10 * Time.deltaTime,
0,
Input.GetAxis("Mouse X") * 10 * Time.deltaTime);
transform.localEulerAngles = rot;
}
}
Comment
Your answer
Follow this Question
Related Questions
The name 'Joystick' does not denote a valid type ('not found') 2 Answers
FPS Camera moving by my left mouse button 1 Answer
Script Issue 2 Answers
Top down camera 1 Answer
how to switch camera 2 Answers