I’m looking for some advice on the best practice to apply to a problem I’m tackling in Unity with Coherence please?
Game type: Multiplayer, 2 - 8 players using Coherence “rooms”
Platform: Unity 2022.3.4f1, Coherence SDK 1.0.0
Situation: Once users connect to a room, I have the coherence bridge call “Spawn” methods of a player handler game object in the scene (“DeSpawn” is called on disconnect). The player handler game object and associated script instantiates the player a coherence sync’d game object that the player controls to compete against other players. All works great.
Problem: I’m building out map / radar functionality and I’d like to have a centralised list of all the player game objects, as a source of truth for this functionality, kept up to date when players leave (disconnect) or are destroyed and respawned. This should be able to be referenced by various components (map, radar etc) to get up to date positions of all players game objects transforms. Currently I’m using FindGameObjectsWithTag to get a list of all the player game objects, but i’m aware this is resource intensive and likely not the best approach to be doing every frame! I’m also aware that i cannot sync Lists or arrays etc
Can you advise me on the best approach to architect a solution, or any guidance as to where to read up further to come to a solution myself?