How to change camera view?

when I’m adding an actor to the scene and hit “Play” the camera is always attached to back of the player. I want to make some kind of Limbo style camera. So, I still want the camera to follow the player (the player should always be at the centre of the screen), but I want it to move only along the Y axis.

Can someone help me with that? Thanks!

I guess you need the transform.LookAt function that you can use like this:

public class Example : MonoBehaviour{

void Update() {
        camera.transform.LookAt(target); // target is your player's transform
    }

}

This will make the camera to look the player no matter where you move the camera

No need for any scripting - make the camera a child of the player gameobject (by dragging in the scene hierarchy), adjust its position to the right and rotate it back to look at the player.

using UnityEngine;
using System.Collections;

public class CameraController : MonoBehaviour {

    public GameObject player;
    private Vector3 offset;

	// Use this for initialization
	void Start () {
        offset = transform.position;
	}
	
	// Update is called once per frame
	void LateUpdate () {
        transform.position = player.transform.position + offset;
	}
}