Menu
CoddyTech

Recap: Chase Camera

Part of the Physics and Gameplay section of Coddy's Unity journey. Lesson 51 of 71.

This recap puts the chapter together: an angle eased with SmoothDamp, an offset turned around the target, and LookAt on a point ahead.

challenge icon

Challenge

Medium

Write the chase camera: it swings round behind the car, a little late.

  1. Keep the camera's yaw in a field, set to car.heading in Start(), and ease it with Mathf.SmoothDamp(yaw, car.heading, ref yawVelocity, smoothTime) each LateUpdate().
  2. Place it at car.transform.position + Quaternion.Euler(0, yaw, 0) * offset.
  3. Aim with transform.LookAt(car.transform.position + car.transform.forward * ahead);.

Press Play and drive in circles. Then Check.

Try it yourself

using UnityEngine;

public class ChaseCamera : MonoBehaviour
{
    public Car car;
    public Vector3 offset = new Vector3(0, 3, -6);
    public float smoothTime = 0.3f;
    public float ahead = 4f;

    void LateUpdate()
    {
    }
}
quiz iconTest yourself

This lesson includes a short quiz. Start the lesson to answer it and track your progress.

All lessons in Physics and Gameplay

Practice on your own: Unity playground