수학 공부중인데 


적을 바라보는 방향벡터를 구하고 그 방향의 x,y,z축의 회전각도값을 atan2로 각각 구한 후 transform.rotation으로 넣어줬음


근데 정작 내가 원하던대로 안나오던데 내가 수식을 잘못 이해했나 싶어서 물어봄


atan2로 들어가는 인수값은 (높이, 밑변)이잖슴? 




7cf3c028e2f206a26d81f6e64e8770


왼쪽부터 회전대상 기준축 x,y,z들이 전방을 바라봤을때 회전좌표계인데


빗변을 적을 대상으로 하는 방향벡터로 치고 각 축에 대해 각도를 구해서 그 축만큼 회전시키면 될줄 알았음


    private void Update()

    {

        if(target != null)

        {

            Vector3 toTargetNormalizedDir = (target.position - transform.position).normalized;


            float xAngle = Mathf.Atan2(toTargetNormalizedDir.y, toTargetNormalizedDir.z) * Mathf.Rad2Deg;

            float yAngle = Mathf.Atan2(toTargetNormalizedDir.x, toTargetNormalizedDir.z) * Mathf.Rad2Deg;

            float zAngle = Mathf.Atan2(toTargetNormalizedDir.y, toTargetNormalizedDir.x) * Mathf.Rad2Deg;


            transform.rotation = Quaternion.Euler(-xAngle, yAngle, 0f);



        }


    }



근데 이상하게 회전되서 내가 수식을 잘못 이해하고 있나 싶은데 당최 모르겠음