private void LateUpdate() { if (hauling) { if (!isInsideShip) { Vector3 newPivotPos = Vector3.Lerp(haulPivot.position, hauler.transform.position, haulFollowSpeed * Time.deltaTime); Vector3 delta = newPivotPos - haulPivot.position; newPivotPos.z = transform.position.z; transform.position = transform.position + newPivotPos - haulPivot.position; float angle = Mathf.Atan2(delta.normalized.y, delta.normalized.x) * Mathf.Rad2Deg; Quaternion targetRot = Quaternion.AngleAxis(angle, Vector3.forward); transform.rotation = Quaternion.Slerp(transform.rotation, targetRot, delta.magnitude * haulRotationSpeed * Time.deltaTime); } else { Vector2 lookDir = hauler.GetLookDirection(); transform.position = hauler.transform.position + new Vector3(insideOffset.x * lookDir.x, insideOffset.y, 0); } } }