Unity Dev: Playing With Cameras

Опубликовано: 11 Июль 2026
на канале: Uber_Garat
225
2

One advantage of Ludum Dare, is it's gotten me fired up about working on my projects. I'll be posting videos periodically of what I'm working on.

Today's topic was specifically creating a static follow cam, and making sure that it was smooth, and moved (in relation to the player) as little as possible. The code in question:

Vector3 newPos = new Vector3(mTarget.transform.position.x, mTarget.transform.position.y + mFollowHeight, mTarget.transform.position.z + mFollowDist);
Quaternion oldLook = transform.rotation;

transform.LookAt(mTarget.transform);
transform.position = Vector3.SmoothDamp(transform.position, newPos, ref pVelocity, 0.1f);
transform.rotation = Quaternion.Lerp(transform.rotation, oldLook, 0.8F);