目的是处理怪物一变走,一边看向某个地方,这里是摄像头,脚本放在怪物身上
Debug.Log("Camera.main.transform.position" + Camera.main.transform.position);
Quaternion newRotation = Quaternion.LookRotation(Camera.main.transform.position- transform.position);
transform.rotation = Quaternion.RotateTowards(transform.rotation, newRotation, 100 * Time.deltaTime);
就下面两行代码,然后如果方向反了,就用transform.position-Camera.main.transform.position,我用的是上面那个方向