
[ad_1]
Following the recommendation posted right here, I made a digicam that follows a participant behind with:
public Camera roomCam;
public GameObject playerGO;
non-public float camMotionSpeed = 5f;
non-public float camRotationSpeed = 50f;
void Start() {
camOffset = new Vector3(0, 3, -8); //x=sideways, y=up/down, z = ahead/again
roomCam.rework.place = playerGO.rework.place + (roomCam.rework.ahead * camOffset.z) + (playerGO.rework.up * camOffset.y);
roomCam.rework.LookAt(playerGO.rework.place);
}
non-public void ReplaceCameraPlace() {
//Move
Vector3 newCamPosition = playerGO.rework.place + (playerGO.rework.ahead * camOffset.z) + (playerGO.rework.up * camOffset.y);
newCamPosition = Vector3.Slerp(roomCam.rework.place, newCamPosition, Time.smoothDeltaTime * camMotionSpeed); //spherical lerp smoothing
roomCam.rework.place = newCamPosition;
//Rotate
Quaternion newCamRotation = Quaternion.LookRotation(playerGO.rework.place - roomCam.rework.place);
newCamRotation = Quaternion.Slerp(roomCam.rework.rotation, newCamRotation, camRotationSpeed * Time.smoothDeltaTime); //spherical lerp smoothing
roomCam.rework.rotation = newCamRotation;
}
non-public void LateUpdate() {
ReplaceCameraPlace();
}
This works appropriately usually, however the smoothing operate which is simply meant to make the digicam slowly “catch up” in place and rotation to the consumer as they transfer round is kind of jerky.
Smoothing particularly is completed by the traces:
newCamPosition = Vector3.Slerp(roomCam.rework.place, newCamPosition, Time.smoothDeltaTime * camMotionSpeed); //spherical lerp smoothing
newCamRotation = Quaternion.Slerp(roomCam.rework.rotation, newCamRotation, camRotationSpeed * Time.smoothDeltaTime); //spherical lerp smoothing
Is there some higher means of smoothing this that may be utilized that won’t create a lot jerking or wobbly jello movement?
Thanks.
[ad_2]