复习UNITY3D网络模块UNET
2017-05-04 17:56
162 查看
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Networking;
public class PlayerController :NetworkBehaviour {
public float traSpeed = 3;//移动的速度
public float rotSpeed = 120;//一秒旋转的角度
// Update is called once per frame
void Update () {
// isLocalPlayer 是 NetworkBehaviour 的内置属性
if (!isLocalPlayer) { //如果不是本地客户端,就返回,不执行下面的操作
return;
}
float h = Input.GetAxis("Horizontal");
float v = Input.GetAxis("Vertical");
transform.Translate(Vector3.forward * v * traSpeed * Time.deltaTime);
//朝某个方向移动
transform.Rotate(Vector3.up * h * rotSpeed * Time.deltaTime); //围绕某轴旋转
}
public override void OnStartLocalPlayer(){
GetComponent<MeshRenderer>().material.color = Color.red; //改变颜色
}
}
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Networking;
public class PlayerController :NetworkBehaviour {
public float traSpeed = 3;//移动的速度
public float rotSpeed = 120;//一秒旋转的角度
// Update is called once per frame
void Update () {
// isLocalPlayer 是 NetworkBehaviour 的内置属性
if (!isLocalPlayer) { //如果不是本地客户端,就返回,不执行下面的操作
return;
}
float h = Input.GetAxis("Horizontal");
float v = Input.GetAxis("Vertical");
transform.Translate(Vector3.forward * v * traSpeed * Time.deltaTime);
//朝某个方向移动
transform.Rotate(Vector3.up * h * rotSpeed * Time.deltaTime); //围绕某轴旋转
}
public override void OnStartLocalPlayer(){
GetComponent<MeshRenderer>().material.color = Color.red; //改变颜色
}
}
相关文章推荐
- 【Unity3D_常用模块】 Socket网络模块(超级详细完整,上线项目中稳定使用着)
- Unity3D unet多人网络示例代码
- Unity5网络模块UNet介绍
- Unity5网络模块UNet介绍
- Unity3D UNet网络组件详解
- Unity5网络模块UNet介绍
- 【Unity3D_常用模块】 Socket网络模块(超级详细完整,上线项目中稳定使用着)
- Unity5网络模块UNet介绍
- 【Unity3D_常用模块】 Socket网络模块(超级详细完整,上线项目中稳定使用着)
- Linux 2.4.x 网络协议栈QoS模块(TC)的设计与实现
- 网络工程师复习结构
- 网络工程师复习笔记1至15章
- Orcal下的中国大陆地热、重力网络数据库(数据库模块设计)
- 2.4.16下网络结构全景图(包含模块接口变量名称)
- 使用ACE做为网络游戏的通讯模块的适合性
- 网线插座板上网络模块接线
- 接口模块不良导致网络短路
- orcal下的中国大陆地热、重力网络数据库(用户网页模块设计)
- Snake.Net网络通讯模块 - IMAP4(三)