我是团结一致的新手,特别是团结网络系统,所以我的问题是:
我正在开发一款纸牌游戏,我需要在脚本中获得网络起始位置,以便我可以实例化我的卡片。我在Unity脚本API中发现了以下内容: enter link description here
所以我制作了一个脚本,我做了这个:
partial_fit
但我在播放场景时在控制台中出现此错误:
public class CardSpawner : NetworkBehaviour
{
public List<GameObject> Cards;
void Start()
{
distributeCards (Cards);
}
[Server]
public void distributeCards (List<GameObject> list){
Transform startPositionTransform;
Vector2 position, finalPosition;
NetworkManager NetM;
List<Transform> startPositionsList;
Vector2 Increment = new Vector2 (1.41f, 0f);
NetM = GetComponent<NetworkManager> ();
for ( int i = 1; i<5 ;i++){
for (int j=0; j<8; j++) {
GameObject CurrentGameObject = list[Random.Range(0,list.Count)];
list.Remove(CurrentGameObject);
switch (i){
case 1:
startPositionsList = NetM.startPositions ;
startPositionTransform = startPositionsList[3];
position =startPositionTransform.position;
finalPosition = position + j * Increment;
Network.Instantiate (CurrentGameObject, finalPosition, Quaternion.identity, 4);
break;
case 2:
//position = startPositionsList [1];
//finalPosition = position + j * Increment;
//Network.Instantiate (CurrentGameObject, position, Quaternion.identity, 4);
break;
case 3:
//position = startPositionsList [2];
//finalPosition = position + j * Increment;
//Network.Instantiate (CurrentGameObject, position, Quaternion.identity, 4);
break;
case 4:
//position = startPositionsList [3];
//finalPosition = position + j * Increment;
//Network.Instantiate (CurrentGameObject, position, Quaternion.identity, 4);
break;
}
}
}
}
}
我不知道这个错误来自哪里,但任何建议都会受到赞赏。谢谢您的时间。