我一直在关注各种 StackOverflow 答案,我想我找到了有效的代码,但在我输入任何代码之前,我必须弄清楚 Unity 是否知道哪个方向是目的。
transform.LookAt(target);
我正在尝试使用上面的代码让敌人对象面对玩家。当我将物体放入场景中时,我如何让 Unity 知道物体的前面是哪条路? (即我将飞机物体放入场景中。“我”知道前面是哪条路,但是“Unity”知道前面是哪条路吗?)
提前感谢您的帮助。
最佳答案
来自 https://docs.unity3d.com/ScriptReference/Transform.LookAt.html
Rotates the transform so the forward vector points at /target/'s current position.
来自 https://docs.unity3d.com/ScriptReference/Vector3-forward.html
Shorthand for writing Vector3(0, 0, 1).
Front 与前向矢量相同,前向矢量指向物体 Z 轴。
关于c# - 如何制作对象脸播放器?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40569137/