How to make the Camera follow the player

In my App. I have the main camera as a child of the player. The Player is always moving upwards when the mouse is held. When the mouse is let go the player falls and the camera is no longer a child and stops following it. When the player is outside of the camera it dies.
But I have some issues.

  1. I want a position just below the half way line of what the camera sees where the player cannot go higher than when the mouse is down.
  2. When the mouse is let go but the player is still falling but not out of the cameras sight and the mouse is then pressed again I want the player to move up to the point it is not allowed to cross and then allow the camera to start moving with it.
    65364-untitled2.png

Sorry for long post. Ive been struggling with it.

I followed the advice in the ‘Rollerball’ demo. It mentioned creating an offset between the camera and the player gameobject, and then moving the camera to keep that same offset no matter what.

Here is the video: Unity Connect

And here is my code for reference (it works in my scenes):
using UnityEngine;
using System.Collections;

public class CameraFollow : MonoBehaviour {

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

}

To make the camera stop at a certain place, you can put a position that tells the camera when to stop. Here’s an example:

private Vector2 velocity;
	public float smoothTimeY;
	public float smoothTimeX;
	public GameObject player;
	public bool bounds;
	public Vector3 minCameraPos;
	public Vector3 maxCameraPos;
	void Start()
	{
		player = GameObject.FindGameObjectWithTag("Player");
	}
	void FixedUpdate()
	{
		float posX = Mathf.SmoothDamp(transform.position.x, player.transform.position.x, ref velocity.x, smoothTimeX);
		float posY = Mathf.SmoothDamp(transform.position.y, player.transform.position.y, ref velocity.y, smoothTimeY);
		transform.position = new Vector3(posX, posY, transform.position.z);
		if (bounds)
		{
			transform.position = new Vector3(Mathf.Clamp(transform.position.x, minCameraPos.x, maxCameraPos.x),
				Mathf.Clamp(transform.position.y, minCameraPos.y, maxCameraPos.y),
				Mathf.Clamp(transform.position.z, minCameraPos.z, maxCameraPos.z));
		}
	}
}