How do I program camera movement

I want to learn the best was to program camera movements. Can anyone give me resources? Specifically I’m trying to make my camera at the start of the game face my player then move into
A top down angle.

Like @Jinkata said, you can do all the from code and also through animation. I prefer through code. I will explain below how you can do what you wanted then give a small example.


So a camera is just like any other object in your scene, with the added functionality of a view port. So you can control it from a script attached to camera or from a different script attached to another object like a game manager or your player.

In your example the camera will follow your player. So the first thing you would want to do is attach the camera as a child to your player. That is simple since all you need to do is drop and drag it to the player gameobject in the hierarchy. This will cause the camera to follow your player.

However, you want it to look at the your player at the start. So simply move it within the scene so that it looks at the player. The next step is to move it toward a different spot above the player and have it look at the player. The rest will be done with code. So create a new script and add it to your camera. Call it “CameraStartEffect”.

Code for CameraStartEffect.cs

// All code here will be within the class

/* Variables */
Vector3 moveToPosition; // This is where the camera will move after the start
float speed = 2f; // this is the speed at which the camera moves
bool started = false; // stops the movement until we want it

/* functions */
void Start () {
  // Since this object as an child the (0, 0, 0) position will be the same as the players. So we can just add to the zero vector and it will be position correctly. 

  moveToPosition = new Vector3 (0, 2, -0.01f); // 2 meters above/ 0.01 meters behind
// If you are allowed to rotate your camera the change the -0.01 to 0

// The following function decides how long to stare at the player before moving
  LookAtPlayerFor (3.5f) ; // waits for 3.5 seconds then starts 

void Update () {
   // so we only want the movement to start when we decide
  if (!started)

   // Move the camera into position
   transform.position = Vector3.lerp (transform.position, moveToPosition, speed);

  // Ensure the camera always looks at the player
  transform.LookAt (transform.parent);

Enumarator LookAtPlayerFor (float time) {
  yield return new WaitForSeconds (time);
   started = true;

You could do this all from code, but I would look into this:

One of the first things it goes over is animating a camera.