A camera in the style of megaman/double dragon?

I want a camera that wont move unless my character is at the edge of the screen. I was thinking of using a trigger attached to my camera but I can’t figure out how to use them.

My code for character movement

using UnityEngine;
using System.Collections;

public class CharacterMovement : MonoBehaviour {

	private Rigidbody2D rb;
   

	public float moveSpeed;

	// Use this for initialization
	void Start () {
		rb = GetComponent<Rigidbody2D>();
	}
	
	// Update is called once per frame
	void Update () {
		float moveHorizontal = Input.GetAxis ("Horizontal");
		float moveVertical = Input.GetAxis ("Vertical");

		Vector2 movement = new Vector2 (moveHorizontal, moveVertical);

		rb.MovePosition(rb.position + movement * moveSpeed);
	}
}

I think one trigger is enough. If you put it to the camera but at z position of the character it should be triggered. you can make it smaller than the screen, on every side the character should be able to transition. If the character exits the trigger on any of those sides you should freeze movement end transition the camera. also sweep the character so he’s on the other side of the screen now. there would be 2 states in which transitions can be possible:

  • character leaves the trigger.
  • character moves in direction from where the transition came after a transition