Camera like editor camera.

I want a script that my camera have the same controls of editor’s camera. I don’t have a good point to start that script. Please help me.

I already wrote that script:

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,
		if (Input.GetKey (KeyCode.Mouse2))
			translation += new Vector3(Input.GetAxis("Mouse Y") * 10 * Time.deltaTime,
			                           Input.GetAxis("Mouse X") * 10 * Time.deltaTime);
		transform.localEulerAngles = rot;

But the camera does not go ahead according to camera rotation, anyone have a solution to this?

This was one of the very first things I ever did in Unity. It was a great little project that got my feet wet with Input and Transforms. I recommend that you being by investigating the Input System and gaining a basic understanding of the Transform Component.

Once you are able to detect when the user is moving the mouse around and hitting buttons and keys, you should be able to start using those inputs to move your camera around. From there it’s just a matter of dialing things in until the result is satisfactory to you. Of course, if you have specific questions along the way then refer back here. The most important thing is that you try to work out some of the ‘how’ on your own, so that you can ask informed, objective, questions.

I was trying to find some already done code for this and came across this old question. I wasn’t able to find a straight given solution so I took the time to make my own. Below is the script that got the camera moving in the game like it does in the scene editor window. (minus the holding shift speeding up the camera it wasn’t necessary for what I was doing but it wouldn’t be a hard addition). Plop this script on the game object with the camera.

using UnityEngine;

public class CameraController : MonoBehaviour
    [SerializeField] float speed = 0.5f;
    [SerializeField] float sensitivity = 1.0f;

    Camera cam;
    Vector3 anchorPoint;
    Quaternion anchorRot;

    private void Awake()
        cam = GetComponent<Camera>();
    void FixedUpdate()
        Vector3 move =;
            move += Vector3.forward * speed;
        if (Input.GetKey(KeyCode.S))
            move -= Vector3.forward * speed;
        if (Input.GetKey(KeyCode.D))
            move += Vector3.right * speed;
        if (Input.GetKey(KeyCode.A))
            move -= Vector3.right * speed;
        if (Input.GetKey(KeyCode.E))
            move += Vector3.up * speed;
        if (Input.GetKey(KeyCode.Q))
            move -= Vector3.up * speed;

        if (Input.GetMouseButtonDown(1))
            anchorPoint = new Vector3(Input.mousePosition.y, -Input.mousePosition.x);
            anchorRot = transform.rotation;
        if (Input.GetMouseButton(1))
            Quaternion rot = anchorRot;
            Vector3 dif = anchorPoint - new Vector3(Input.mousePosition.y, -Input.mousePosition.x);
            rot.eulerAngles += dif * sensitivity;
            transform.rotation = rot;