[英]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
函数返回值从-1f
到1f
或0f
到1f
。 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. 如果你正在做什么,需要之间的数字
-1f
至1f
或0f
到1f
,那么你就需要从乘值Input.GetAxis
功能与任何其他号码。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.