Search Unity

Help Wanted add the instantiated object to the list

Discussion in 'Multiplayer' started by Zeohack, Jun 15, 2021.

  1. Zeohack

    Zeohack

    Joined:
    Sep 17, 2020
    Posts:
    11
    I instantiate an object with photonNetwork, in the function below I sync a 2d string and add it to the list, but it gives an error on the line I want to add to the list


    Code (CSharp):
    1. private void InitialSetup1()
    2.     {  
    3.         AddPiece(redGolem, red, 6, 6);
    4.         AddPiece(redEye, red, 4, 6);
    5.         AddPiece(redMuc, red, 7, 6);
    6.     //
    7.     }
    8.  
    9. public void AddPiece(GameObject prefab, Player player, int col, int row)
    10.     {
    11.   Vector2Int gridPoint = Geometry.GridPoint(col, row);
    12.    GameObject pieceObject = Instantiate(prefab, Geometry.PointFromGrid(gridPoint), Quaternion.identity, 0, null);
    13.  
    14. player.pieces.Add(pieceObject);
    15.  pieces[col, row] = pieceObject;
    16.  
    17.      
    18.         return pieceObject;
    19.     }
     
    Last edited: Jun 17, 2021
  2. Zeohack

    Zeohack

    Joined:
    Sep 17, 2020
    Posts:
    11
    Any idea?
     
unityunity