unity 的一些API-01
Posted redlkop
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了unity 的一些API-01相关的知识,希望对你有一定的参考价值。
public static float GetAxis(string axisName);
看下原话解释:
Returns the value of the virtual axis identified by axisName
.
The value will be in the range -1...1 for keyboard and joystick input. If the axis is setup to be delta mouse movement, the mouse delta is multiplied by the axis sensitivity and the range is not -1...1.
This is frame-rate independent; you do not need to be concerned about varying frame-rates when using this value.
大意:返回一个虚轴的值给对象,这个值在-1到1之间,而鼠标则不是-1到1. 如官方给出的代码:
public float speed = 10.0F;
public float rotationSpeed=100.0F;
void()
{float translation = Input.GetAxis("vertical")*speed;
float rotation = Input.GetAxis("Horizontal")*rotationSpeed;
translation*=Time*deltaTime;
rotation*=Time.deltaTime;
transform.Translate(0,0,translation);
transform.Rotate(0,rotation,0);
以上是关于unity 的一些API-01的主要内容,如果未能解决你的问题,请参考以下文章
Unity报错:Read only asset Packages/com.xxxxx.xxx.xxxx/Editor/VSCodeDiscovery.cs.IPGSD has no meta(代码片段