Unity Networking: Client spawning and controlling objects

Hi!

I’m stuck on this problem for days and can’t figure out a solution…

My project has player objects with scripts which access the webcam, track features and instantiate spheres for the tracked points. Locally I instantiate these spheres on an image of the webcam texture to show the found features. Now I need to alter it to work as a LAN multiplayer so that all connected clients can see the tracked points of each player. I can simply NetworkServer.Spawn(obj) the spheres from my host which is than seen on the clients but can’t find a solution for my clients.

What I want to achieve is: Spawn each sphere and still have an array with references to them on my client to change their position in another script which access the array named points in this script.

void Start ()
{
points = new GameObject[FaceFeatureCount];

    for (int i = 0; i < points.Length; i++) {
        GameObject sphere = Instantiate(spherePrefab);
        if (FaceRoot)
        {
            sphere.transform.parent = FaceRoot.transform;
            sphere.transform.position = FaceRoot.transform.position;
        }
        else
        {
            sphere.transform.parent = transform;
            sphere.transform.position = transform.position;
        }
        sphere.transform.localScale = FeatureSize;
    FaceRoot.transform.localScale += new Vector3(0.02f,0.02f,0.02f);
        sphere.GetComponent<MeshRenderer>().enabled = true;
        NetworkServer.Spawn(sphere);
        //CmdSpawn(sphere);
        points *= sphere;*

}
}
[Command]
private void CmdSpawn(GameObject go)
{
//GameObject sphere = (GameObject)Instantiate(spherePrefab, transform.position, transform.rotation);
NetworkServer.Spawn(go);
}
public GameObject[] getFeatures(){

  •   return points;*
    
  • }*
    I’m hoping someone can help me :frowning:

I have fixed it myself today. If somebody stumbles upon this question while experiencing the same problem here is my solution:
I call CmdSpawnSphere(i); in my start loop and for (int i = 0; i < points.Length; i++) CmdPositionSphere(i, points*.transform.position); in my update.*
The performance is enough for my project.
The commands do the following:
[Command]
private void CmdPositionSphere(int number, Vector3 position)
{
string name = “FaceSphereID” + netId + “No” + number;
GameObject sphere = GameObject.Find(name);
sphere.transform.position = position;
}

[Command]
private void CmdPositionSphere(int number, Vector3 position)
{
string name = “FaceSphereID” + netId + “No” + number;
GameObject sphere = GameObject.Find(name);
sphere.transform.position = position;
}
Note that in my case another class updated the transforms of the points list.