Input.GetAxis 获取轴
生活随笔
收集整理的這篇文章主要介紹了
Input.GetAxis 获取轴
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
static function?GetAxis?(axisName?: string) : float
Description描述
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.
使用控制器和鍵盤輸入時此值范圍在-1到1之間。如果坐標軸設置為鼠標運動增量,鼠標增量乘以坐標軸靈敏度的范圍將不是-1到1 。
// A very simplistic car driving on the x-z plane. // 一個十分簡單的在x-z平面的駕車例子 var speed : float = 10.0; var rotationSpeed : float = 100.0;function Update () {// Get the horizontal and vertical axis.//獲取橫向和縱向坐標軸// By default they are mapped to the arrow keys.//默認情況下他們關聯到方向鍵上// The value is in the range -1 to 1//值的范圍是在-1到1之間var translation : float = Input.GetAxis ("Vertical") * speed;var rotation : float = Input.GetAxis ("Horizontal") * rotationSpeed;// Make it move 10 meters per second instead of 10 meters per frame...// 使它每幀移動10米變為每秒移動10米...translation *= Time.deltaTime;rotation *= Time.deltaTime;// Move translation along the object's z-axis//沿著z軸平移對象transform.Translate (0, 0, translation);// Rotate around our y-axis//以我們的y軸為中心旋轉transform.Rotate (0, rotation, 0); } // Performs a mouse look. //執行一個鼠標觀察 var horizontalSpeed : float = 2.0; var verticalSpeed : float = 2.0; function Update () {// Get the mouse delta. This is not in the range -1...1//獲取鼠標增量,范圍不在-1...1var h : float = horizontalSpeed * Input.GetAxis ("Mouse X");var v : float = verticalSpeed * Input.GetAxis ("Mouse Y");transform.Rotate (v, h, 0); }?
轉載于:https://www.cnblogs.com/vincentDr/p/3678354.html
總結
以上是生活随笔為你收集整理的Input.GetAxis 获取轴的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Transform.Rotate 旋转
- 下一篇: 学习di'z地址