Skip to main content

FollowCamera

A class in Root.Township, the global namespace.

Debug camera that slowly orbits a group of transforms and zooms to keep them in frame. Arrow keys change the focus target.

Constructors​

MemberWhat it is
FollowCamera()Unity makes components itself; use AddComponent or spawn a prefab instead of new.

Fields​

12 private and internal fields
MemberWhat it is
private float cameraTiltCamera tilt in degrees.
private int focusIndex of the focused transform.
private Transform[] followingTransforms the camera can frame.
private float heightBufferExtra height added around the framed group.
private bool[] isContainedPer target, whether it is within maximumDistance of the focus this frame.
private float lerpRotationRotation smoothing speed.
private float lerpSpeedPosition smoothing speed.
private float maximumDistanceTargets further than this from the focus are left out of the frame.
private float rotationCurrent orbit angle in radians.
private float rotationSpeedOrbit speed in radians per second.
private Camera topicThe camera on this object.
private float widthBufferExtra width added around the framed group.

Methods​

2 private and internal methods
MemberWhat it is
private void Awake()Gets the camera and sizes the contained array.
private void LateUpdate()Picks targets near the focus, frames them with the buffers and lerps the camera there while orbiting. Logs every frame.