Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only. On July 15, Unity Discussions will become read-only until July 18, when the new design and the migrated forum contents will go live. Read our full announcement for more information and let us know if you have any questions.

Question add the instantiated object to the list

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

  1. Zeohack

    Zeohack

    Joined:
    Sep 17, 2020
    Posts:
    15
    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:
    15
    Any idea?