Weapon是玩家对象的子对象,子对象Weapon不能被视为玩家对象的一部分,对吧?所以,我需要使用 NetworkIdentity.AssignClientAuthority() 来赋予非玩家对象本地权限。
public class Weapon: NetworkBehaviour
{
void Start()
{
// how to get the conn?
GameObject.GetComponent<NetworkIdentity>().AssignClientAuthority(conn);
}
void Update()
{
CmdShot();
}
[Command]
void CmdShot()
{
// shot...
}
}