我有一个问题,我无法从客户端生成选定的对象。当主机执行该操作时,它可以完美地工作,但当客户端尝试它时,它就不行了。当客户端尝试它时,我收到以下错误:“SpawnWithClientAuthority 播放器对象不是播放器”。这很令人困惑,因为它在由主机执行时完美运行。
此特定部分的代码如下:
private void updateAppearance(GameObject newObject)
{
Destroy(appearance);
hiderModel.SetActive(false);
int newObjectNum = propNames.IndexOf(newObject.name);
activePropIndex = newObjectNum;
Debug.Log(newObjectNum);
newObject = (GameObject)Instantiate(props[newObjectNum], playerCam.gameObject.transform);
newObject.transform.localPosition = new Vector3(0, getObjectHeight(newObjectNum), 0);
NetworkServer.SpawnWithClientAuthority(newObject, gameObject); <--- This part gives the error
appearance = newObject;
appearance.transform.localPosition = new Vector3(0, appearance.transform.localPosition.y, 0);
}
要生成的对象设置了 localAuthority 并对其进行了网络转换。该对象注册为可生成对象,它是我传递给 SpawnWithClientAuthority 方法的实例化预制件。据我所读,这应该允许该功能工作,但不幸的是它没有。
有想法该怎么解决这个吗?
提前致谢