public class CameraController : MonoBehaviour {
public GameObject Player;
Vector3 offset;
Vector3 movePos;
void Start () {
offset = transform.position - Player.transform.position;
}
void Update() {
if (Input.GetMouseButton (1)) {
transform.RotateAround (Player.transform.position, Vector3.up, Input.GetAxis ("Mouse X") * 50.0f * Time.deltaTime);
}
}
void LateUpdate() {
movePos = Player.transform.position + offset;
transform.position = Vector3.Lerp (transform.position, movePos, 5.0f * Time.deltaTime); //Lerp : 보간
}
}
카메라가 Player캐릭터 중심으로 회전하고 따라가고 하는건데
회전만 하거나 이동만 했을때 잘 따라가긴 하는데
따라가면서 회전할때 고정된 offset때문에 문제가 생기는걸 알았지만
쉬운문제같은데...어떤식으로 해야하는건지 도저히 감을 못잡겠어요...
ㄴ 저도 잘은 모르겠지만, 자식으로 두는거 보다 따로 계산하는게 좋을거라고 해서요...