Top down follow camera

Looking to get a camera and spotlight to follow the player. Not sure how to do this. Working in C#.

This is my latest attempt.

using UnityEngine;
using System.Collections;

public class MainCamera : MonoBehaviour {
GameObject MainCam;
GameObject Spotlight;
public float LockedY = 0;
public PlayerControl Hero;
// Use this for initialization
void Start () {

}

// Update is called once per frame
void Update () {
//transform.position = new Vector3(Hero.transform.x, LockedY, Hero.transform.z);

}
}

What is this script attached to? If you are using transform.position, it needs to be attached to both the camera and spotlight. If it’s on something else and you are dragging the camera and spotlight onto the script (in inspector) you need to move the position of the MainCam and Spotlight variables. I.e:

MainCam.position
Spotlight.position

If you decide to use transform.position and attach it to the camera and spotlight, I would recommend defining transform.position in the Start function in a seperate variable. So you don’t have to keep calling this value in the update function.