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