简体   繁体   English

统一; Vector3.Forward,更改x位置,未声明z位置

[英]Unity; Vector3.Forward, changes x position, not declared z position

Can someone explain to me why when I declare "Vector3.Forward" or the equivalent "Vector3(0,0,1)" it changes the gameObject in the X-position rather than the Z position? 有人可以向我解释为什么当我声明“ Vector3.Forward”或等效的“ Vector3(0,0,1)”时,它会将游戏对象更改为X位置而不是Z位置吗? It's really simple, but I'm lost for words. 这确实很简单,但我一言不发。 The third variable where the 1 is located is for the z-position, and not for the x-position. 1所在的第三个变量用于z位置,而不用于x位置。 Right? 对?

The code works, I'm just confused about the logic behind it. 该代码有效,我只是对其背后的逻辑感到困惑。

What do you mean by "it changes"? “变化”是什么意思? are you . 你是 。 Translate -ing it? 翻译 -ing吗?

If you are, you're probably translating it in the Local Space. 如果是这样,您可能正在本地空间中对其进行翻译。 If you want to translate in the World Space, add the second parameter to .Translate like this: 如果要在世界空间中翻译,请向.Translate添加第二个参数,如下所示:

transform.Translate(Vector3.forward * Time.deltaTime, Space.World);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM