简体   繁体   English

Unity3D为什么将轴与SPEED相乘?

[英]Unity3D why multiply axis with SPEED?

Im pretty new in programming in Unity... 我在Unity编程中相当新...

So my question is: 所以我的问题是:

Why you multiply the 为什么要乘以

Input.GetAxis("VertOrHorz") * speed

with speed. 与速度。 Because I was used to move things with the += or -= operator. 因为我习惯于使用+ =或-=运算符移动事物。

Could anyone please do me a favour and explain it to me :). 谁能帮我一个忙,然后向我解释一下:)。

Thanks in advance 提前致谢

Jakob 雅各布

The Input.GetAxis function returns values from -1f to 1f or 0f to 1f . Input.GetAxis函数返回值从-1f1f0f1f This value range is so little to the extent that it cannot move an Object. 该值范围很小,以至于无法移动对象。

For example, adding force to a Rigidbody with a value of 0.5f returned from Input.GetAxis wont be able to do anything. 例如,添加力到Rigidbody ,值为0.5f从返回Input.GetAxis将无法做任何事。

By multiplying it with another number( speed ), you will be able to get a number big enough to actually move the Object. 通过将其乘以另一个数字( speed ),您将可以获得足够大的数字以实际移动对象。

If you are doing anything that requires a number between -1f to 1f or 0f to 1f , then you do not need to multiply the value from the Input.GetAxis function with any other number. 如果你正在做什么,需要之间的数字-1f1f0f1f ,那么你需要从乘值Input.GetAxis功能与任何其他号码。

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

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