1. 程式人生 > >unity 的一些API-01

unity 的一些API-01

rotate set vertical multi his value setup sla .get

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