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; //改变颜色
}
}