如何制作对象脸播放器?

how do I make object face player?

我一直在关注各种 Whosebug 答案,我想我找到了有效的代码,但在我输入任何代码之前,我必须弄清楚 Unity 是否知道 "front" 的对象。

transform.LookAt(target);

我正在尝试使用上面的代码让敌人对象面对玩家。当我将物体放入场景中时,我如何让 Unity 知道物体的前面是哪条路? (即我将飞机物体放入场景中。"I" 知道前面是哪条路,但是 "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).

前面与前向矢量相同,前向矢量指向物体Z轴。