Unity3D 学习案例四
来源:互联网 发布:商城购物车数据库设计 编辑:程序博客网 时间:2024/05/21 18:38
function Start () {
}
var speed :int = 5;
var newobject:Transform;
var sdshu:int = 0;
var xmshu:int = 0;
function Update () {
var x :float=Input.GetAxis("Horizontal") *Time.deltaTime*speed;
var z :float=Input.GetAxis("Vertical") *Time.deltaTime*speed;
//移动功能
transform.Translate(x,0,z);
//print("sheji;"+x);
//开火功能
if (Input.GetButtonDown("Fire1")){
var n:Transform = Instantiate(newobject,transform.position,transform.rotation);
var fwd: Vector3 = transform.TransformDirection(Vector3.forward);
n.rigidbody.AddForce(fwd*2800);
sdshu++;
gameObject.Find("wenzi").GetComponent(GUIText).text="射弹数:"+sdshu+" 消灭数:"+xmshu;
}
//旋转功能
if(Input.GetKey(KeyCode.Q)){
transform.Rotate(0,-25*Time.deltaTime,0,Space.Self);
}
if(Input.GetKey(KeyCode.E)){
transform.Rotate(0,25*Time.deltaTime,0,Space.Self);
}
if(Input.GetKey(KeyCode.Z)){
transform.Rotate(-25*Time.deltaTime,0,0,Space.Self);
}
if(Input.GetKey(KeyCode.X)){
transform.Rotate(25*Time.deltaTime,0,0,Space.Self);
}
//升高降低镜头
if(Input.GetKey(KeyCode.H)){
transform.Translate(0,5*Time.deltaTime,0);
}
if(Input.GetKey(KeyCode.N)){
transform.Translate(0,-5*Time.deltaTime,0);
}
}
}
var speed :int = 5;
var newobject:Transform;
var sdshu:int = 0;
var xmshu:int = 0;
function Update () {
var x :float=Input.GetAxis("Horizontal") *Time.deltaTime*speed;
var z :float=Input.GetAxis("Vertical") *Time.deltaTime*speed;
//移动功能
transform.Translate(x,0,z);
//print("sheji;"+x);
//开火功能
if (Input.GetButtonDown("Fire1")){
var n:Transform = Instantiate(newobject,transform.position,transform.rotation);
var fwd: Vector3 = transform.TransformDirection(Vector3.forward);
n.rigidbody.AddForce(fwd*2800);
sdshu++;
gameObject.Find("wenzi").GetComponent(GUIText).text="射弹数:"+sdshu+" 消灭数:"+xmshu;
}
//旋转功能
if(Input.GetKey(KeyCode.Q)){
transform.Rotate(0,-25*Time.deltaTime,0,Space.Self);
}
if(Input.GetKey(KeyCode.E)){
transform.Rotate(0,25*Time.deltaTime,0,Space.Self);
}
if(Input.GetKey(KeyCode.Z)){
transform.Rotate(-25*Time.deltaTime,0,0,Space.Self);
}
if(Input.GetKey(KeyCode.X)){
transform.Rotate(25*Time.deltaTime,0,0,Space.Self);
}
//升高降低镜头
if(Input.GetKey(KeyCode.H)){
transform.Translate(0,5*Time.deltaTime,0);
}
if(Input.GetKey(KeyCode.N)){
transform.Translate(0,-5*Time.deltaTime,0);
}
}
阅读全文
0 0
- Unity3D 学习案例四
- Unity3D 学习案例一
- Unity3D 学习案例二
- Unity3D 学习案例三
- Unity3D 学习案例五
- Unity3D 学习案例六
- unity3d学习(四)
- XLT的unity3D学习笔记(四)
- Unity3D学习(四)射箭游戏
- Unity3D学习入门笔记(四)
- cobol学习之四字典案例
- Spark学习四:网站日志分析案例
- ExtJS学习:MVC模式案例(四)
- flume 学习四:各种执行案例二
- unity3d---案例分析
- unity3d socket编程案例
- Unity3D学习 愤怒的小鸟之Play界面(四)
- Photon + Unity3D 线上游戏开发 学习笔记(四)
- 二维码生成代码
- ros中的hector_mapping节点详细介绍
- HTTP2.0与HTTP1.0的区别
- APP登录界面(网页仿制版)
- 类图的关系
- Unity3D 学习案例四
- 10 分钟理解 BFC 原理
- 如何运行vue项目
- [bzoj2282][Sdoi2011]消防(树上乱搞+二分)
- Android studio快捷键大全 和 eclipse对照(原)
- 数组方法总结归纳!!!
- [转]TensorFlow 在使用过程中可能遇到的问题及解决办法
- 数据结构——线性表
- KD-Tree解决空间最短距离的利器