坦克移动
来源:互联网 发布:管家婆辉煌网络破解版 编辑:程序博客网 时间:2024/04/28 07:43
using UnityEngine;using System.Collections;using UnityStandardAssets.Utility;using TouchControlsKit;public class TankMove : MonoBehaviour {// 坦克移动变量public float moveSpeed = 20.0f;public float rotSpeed = 50.0f;private Rigidbody rbody;private Transform tr;// jianpanprivate float h,v;private PhotonView pv = null;//主摄像机追踪decampivot游戏对象public Transform camPivot;//坦克位置和旋转信息变量设置初始值private Vector3 currPos = Vector3.zero;private Quaternion currRot = Quaternion.identity;//12月4日改动void Awake () {rbody = GetComponent<Rigidbody> ();tr = GetComponent<Transform> ();pv = GetComponent<PhotonView> ();//12月4日改动pv.synchronization = ViewSynchronization.Unreliable;pv.observed = this;if (pv.isMine) {// 为主摄像机中的SmoothFollow脚本设置追中对象Camera.main.GetComponent<SmoothFollow> ().target = camPivot;//将Rigidbody重心设置为最低值,为了与现实中坦克类似rbody.centerOfMass = new Vector3 (0.0f, -0.5f, 0.0f);} else {rbody.isKinematic = true;//12月4日改动}currPos = tr.position;currRot = tr.rotation;}void OnPhotonSerializeView(PhotonStream stream,PhotonMessageInfo info){//传送本地坦克位置和炮塔信息if (stream.isWriting) {stream.SendNext (tr.position);stream.SendNext (tr.rotation);} else {currPos = (Vector3)stream.ReceiveNext();currRot = (Quaternion)stream.ReceiveNext();}}// Update is called once per framevoid Update () {if (pv.isMine) {//h = Input.GetAxis ("Horizontal");h = InputManager.GetAxis( "dPad", "Horizontal" );;v = InputManager.GetAxis( "dPad","Vertical");//旋转和移动处理Debug.Log(h);tr.Rotate (Vector3.up * rotSpeed * h * Time.deltaTime*0.25f);tr.Translate (Vector3.forward * v * moveSpeed * Time.deltaTime*0.25f);} else {tr.position = Vector3.Lerp (tr.position, currPos, Time.deltaTime * 3.0f);tr.rotation = Quaternion.Slerp (tr.rotation, currRot, Time.deltaTime * 3.0f);}}}
0 0
- 坦克移动
- 坦克大战_坦克移动
- Tank大战,坦克移动
- html5坦克大战中坦克移动代码。
- 坦克小战之自己坦克移动
- 坦克的移动和旋转
- 07-html5游戏坦克大战第三战(坦克移动)
- 坦克游戏教程二:实现坦克移动以及方向控制
- 坦克大战_敌方坦克移动并发子弹
- MFC与坦克大战系列(奇迹冬瓜)---chapter3(坦克属性定义与坦克的平滑移动)
- 【Java_项目篇<1>】--JAVA实现坦克大战游戏--坦克移动+添加敌方坦克(二)
- 游戏制作之一 坦克的移动
- 利用UImageView实现简单坦克移动操作
- Demon_Tank (坦克移动发射子弹)
- 坦克
- cocos2d-x游戏开发系列教程-坦克大战游戏之虚拟手柄控制坦克移动
- HTML5-坦克大战一完成坦克上下左右移动的功能(一)
- HTML5实现一个能够移动的小坦克
- 最新Mac OS X 10.12.1 安装cocoapods及使用详解
- 接口 - interface
- STL中队列(queue)的使用方法
- Hbase WAL线程模型源码分析
- Spring boot使用ProxyFilter进行服务代理
- 坦克移动
- 巧妙平方数
- Oracle常用函数
- CentOS 安装Nginx
- Qt自动生成ui_xxx.h和moc_xxx.cpp
- ruby on rails 的模型测试
- webupload 上传插件 完美版 - 拿走直接用
- 富文本编辑器,CKEditor与 CKFinder 整合并实现文件上传功能
- websocket 与Socket.IO介绍