public Transform target;
Vector3 RelativeOptionalPosition = new Vector3(0, 1.5f, 0);
float Sensetive = 30f;
void Start()
{
}
void FixedUpdate()
{
transform.Translate(new Vector3(Input.GetAxis("Mouse X") * Time.deltaTime * Sensetive, -Input.GetAxis("Mouse Y") * Time.deltaTime * Sensetive, 0));
Vector3 RelativePosition = target.position - transform.position + RelativeOptionalPosition;
Quaternion Current = transform.localRotation;
Quaternion Dest = Quaternion.LookRotation(RelativePosition);
transform.localRotation = Quaternion.Slerp(Dest, Current, Time.deltaTime);
}
지금 자습서 보면서 공부중인데 문제가 생겼어요....
위코드는 자습서에서 나온거 코드좀 가져다가 수정한건데 마우스를 움직이면 target 을 기준으로 움직이는데 움직일때 마다 간격이 점점 벌어집니다. 어떻게 해결해야 하나요
음.... 그러니까 마우스를 움직이면 target을 바라보는 상태로 카메라가 움직이는데 움직일떄마다 카메라와 target 의 거리가 점점 증가하는게 문제에요
위에 스크립트는 카메라에 연결되어 있고 카메라는 target의 자식 객체로 설정하진 않아서 포지션값이 target 기준이 아니에요
저거는 자습서에 있는 코드 가져온건데 문제있나요?