Create a unique array for all players in the scene

Options

Hello everyone,

I am developing an AR Program in unity and I need an Array or a List of Gameobjects in the Scene and I need all players to have access to the same Array with the same elements in it.

The problem is, when a player add an element to this array, for the other players is this array still empty and I need first to send a RPC massage to them to add this new element to the Array.

But I prefer to have a uniqe Array which get updated bei any Change (add or delete) for all players in the scene.

I don't know if there is a solution! Can anyone help me?

Comments

  • Tobias
    Options

    What do you mean by "I prefer to have a uniqe Array which get updated bei any Change"?

  • Eliassss
    Options

    I mean an Array which changes for all players whit or without using RPC.

    I have an Array named "signs" in a Script named "Sign controller" which contains list of all signs used in the scene.

    When player 1 create a new Sign in the scene, player 1 adds the name of the Sign in the "signs" Array.

    but for player 2:

    signs[0] = null

    even if player 1 do:

    [PunRPC]

    private void AddToArray( string nameOfSign){

    signs.append( nameOfSign).toArray();

    }

    for player 1 I get

    signs[0] = nameOfSign

    but still I get for player 2:

    signs[0] = null

  • Tobias
    Options

    Networked arrays are complicated to implement. Who is right, when everyone happens to change some values at the same time? Who decides?

    PUN 2 doesn't have this.

    What is close to this, are the Custom Properties, which are a Hashtable. Everyone can change them via SetCustomProperties and there is an option to have the server apply changes only under certain conditions.

    Read up on Custom Properties in the docs. There are more pages showing their use and more features.


    Fusion has networked arrays in it's state but the Host/Server has the authority over those and not everyone can just change the values in the array.