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
MediumWrite the chase camera: it swings round behind the car, a little late.
- Keep the camera's
yawin a field, set tocar.headinginStart(), and ease it withMathf.SmoothDamp(yaw, car.heading, ref yawVelocity, smoothTime)eachLateUpdate(). - Place it at
car.transform.position + Quaternion.Euler(0, yaw, 0) * offset. - 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()
{
}
}
This lesson includes a short quiz. Start the lesson to answer it and track your progress.
All lessons in Physics and Gameplay
1Rigidbody
Gravity and MassPush with AddForceJump with an ImpulseFixedUpdate for PhysicsVelocityKinematic BodiesRecap: Launch Pad4Coroutines
InvokeInvokeRepeating, CancelInvokeYour First CoroutineLoops in CoroutinesStopping CoroutinesRecap: Countdown10Project: Arena Escape
The ArenaHunters2Collisions
OnCollisionEnterWhat Did I Hit?Break on ImpactStanding on the GroundBounce and FrictionCollider ShapesRecap: Breakable WallPractice on your own: Unity playground