공부/개념 & 유용한 내용
XZ 평면에서 특정 방향을 바라보도록 회전
ENUM01
2023. 8. 23. 15:18
1
2
3
4
5
6
7
8
9
10
|
private void RotateToTargetXZ(Transform target)
{
//XZ 평면에서의 타겟 방향
Vector3 targetForwardOnGround = Vector3.ProjectOnPlane(target.forward, Vector3.up);
//targetForwardOnGround로 회전할 각도
float targetYRotation = Vector3.SignedAngle(Vector3.forward, targetForwardOnGround, Vector3.up);
transform.rotation = Quaternion.Euler(90, targetYRotation, 0);
}
|
cs |
미니맵 구현 시 플레이어 아이콘, 시야 아이콘 등에 적용할 수 있다.