找回密码
 立即注册
查看: 3890|回复: 66

[脚本] 飞行模式漫游键盘源码

[复制链接]
发表于 2013-7-25 11:06 | 显示全部楼层 |阅读模式
#pragma strict
var MoveSpeed = 20;
var RotateSpeed = 20;
function Start () {
}
function Update () {
  if(Input.GetKey(KeyCode.W)||Input.GetKey(KeyCode.UpArrow))
  {
     transform.Translate(Vector3.forward*Time.deltaTime*MoveSpeed);
  }
  else if(Input.GetKey(KeyCode.S)||Input.GetKey(KeyCode.DownArrow))
  {
     transform.Translate(Vector3.forward*Time.deltaTime*-MoveSpeed);
  }
    else if(Input.GetKey(KeyCode.A)||Input.GetKey(KeyCode.LeftArrow))
  {
     transform.Translate(Vector3.left*Time.deltaTime*MoveSpeed);
  }  
  else if(Input.GetKey(KeyCode.D)||Input.GetKey(KeyCode.RightArrow))
  {
     transform.Translate(Vector3.right*Time.deltaTime*MoveSpeed);
  }
  else if(Input.GetKey(KeyCode.Q)||Input.GetKey(KeyCode.Insert))
  {
     transform.Rotate(Vector3.up, Time.deltaTime*-RotateSpeed, Space.World);
  }
  else if(Input.GetKey(KeyCode.E)||Input.GetKey(KeyCode.Home))
  {
     transform.Rotate(Vector3.up, Time.deltaTime*RotateSpeed, Space.World);
  }
    else if(Input.GetKey(KeyCode.Z)||Input.GetKey(KeyCode.Delete))
  {
     transform.Translate(Vector3.up*Time.deltaTime*RotateSpeed);
  }
    else if(Input.GetKey(KeyCode.C)||Input.GetKey(KeyCode.End))
  {
     transform.Translate(Vector3.down*Time.deltaTime*RotateSpeed);
  }
    else if(Input.GetKey(KeyCode.R)||Input.GetKey(KeyCode.PageUp))
  {
     transform.Rotate(Vector3.left*Time.deltaTime*RotateSpeed);
  }
  else if(Input.GetKey(KeyCode.F)||Input.GetKey(KeyCode.PageDown))
  {
     transform.Rotate(Vector3.right*Time.deltaTime*RotateSpeed);
  }
  else if(Input.GetKey(KeyCode.KeypadPlus))
  {
     MoveSpeed=MoveSpeed+1;
  }
  else if(Input.GetKey(KeyCode.KeypadMinus))
  {
     MoveSpeed=MoveSpeed-1;
  }
     
}
发表于 2014-2-19 11:27 | 显示全部楼层

感谢楼主的无私分享!{:soso__11402694654016840197_7:}
发表于 2014-4-25 14:06 | 显示全部楼层
{:5_427:}{:5_427:}{:5_427:}{:5_427:}
发表于 2014-5-18 08:58 | 显示全部楼层
谢谢楼主啊!
发表于 2014-6-10 10:21 | 显示全部楼层
感谢楼主的无私分享!
发表于 2014-11-14 10:41 | 显示全部楼层

感谢楼主的无私分享!{:soso__11402694654016840197_7:}
发表于 2017-3-3 09:37 | 显示全部楼层
很不错
发表于 2017-3-3 09:24 | 显示全部楼层
好帖就是要顶
发表于 2017-3-3 09:43 | 显示全部楼层
顶顶多好
发表于 2017-3-3 09:50 | 显示全部楼层
真心顶
懒得打字嘛,点击右侧快捷回复 【右侧内容,后台自定义】
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Unity开发者联盟 ( 粤ICP备20003399号 )

GMT+8, 2024-5-5 00:57 , Processed in 0.123448 second(s), 26 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表