asset store ---Mirror
github --- parrelSync
创建3d object 作为人物
properties添加:
1. network identity
2. network transform
3. player scripts
4. 做为prefabs预制件,client进入时生成
网络配置
新建 empty object
添加 network manager
添加 network manager HUD
简单的人物移动脚本
using Mirror;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Player : NetworkBehaviour
{
void HandleMovement(){
if(isLocalPlayer){
float h=Input.GetAxis("Horizontal");
float v=Input.GetAxis("Vertical");
Vector3 movement=new Vector3(h*0.1f,v*0.1f,0);
transform.position=transform.position+movement;
}
}
void Update(){
HandleMovement();
}
}