Using Object Pooling for Network Instantiated items

Options
HI!

I have a problem where I am not sure what is the ultimate best way of handling this... My goal is to run my game on Mobile.. .so I have been using a poolilng system for my objects....
private void FoodGrowth(bool gamestarted=true){
//	Debug.Log ("Food Growth");
		int growth = 5;
		if (gamestarted == false) {
			growth = maxfood;
		   }

		if (_foodcount <= maxfood)
		for(int i=0; i<growth; i++) {	
	            {			
				//GameObject go;
				Vector2 foodpos = new Vector2(Random.Range(1f,26f),Random.Range(1f,13f));				
				GameObject instance = CFX_SpawnSystem.GetNextObject(freshfood);
				instance.transform.position =  new Vector3(foodpos.x ,foodpos.y,-2f);
				_foodcount += 1;
			}
		}
		uiFoodCount.text = "Food Available: " + _foodcount;
	}


where the line:
GameObject instance = CFX_SpawnSystem.GetNextObject(freshfood);

should be now replaced with
PhotonNetwork.Instantiate(freshfood, new Vector3(foodpos.x ,foodpos.y,-2f), Quaternion.identity, 0);

but I need thousands of food sources for users to run around and eat.... i am worried I am going to run into problems if I want all the food synced across the game..

these food objects are just simple objects... very low triangle.. just need a way of creating them and having them not bog down the system where I am worried if I don't use object pooling things will just grind down to a halt.

Thanks...

Comments

  • vadim
    Options
    You should not instantiate and synchronize thousands of network objects. Instead, synchronize more generic game parameters like quantity of food of given type and food positions if required. For such synchronization few (or even single) "managing" objects are enough.
    Also you may skip many data sync if local logic implemented consistently between clients (e.g. no positions sync required if random seed is the same on all clients)
  • I have attempted to see what kind of a impact making each player populate "400" food each... not a good option as I have just viewed the server insights and seen that with only 4 people connected I have hit the 500+ messages per second threshold.... not cool.

    So in the game there has to be a Rush for the food.. so everybody see's everybody's food on the board... and sync is required.... so as if player 1 is rushing for FOOD A; then gets the FOOD A, player 2 should see FOOD A disappear and then have to turn away as FOOD B would be a better option....

    so with mass amounts of food there is a frenzy of excitement... having a array of food positions getting sent seems like the answer.. and having the array processed locally and making the food appear/destroyed locally based on the array.... wondering if there is any best practices already established for such a case.

    Update:

    So lets say I don't add a PhotonView to a Object that Instantiated over the network... I can't use a network destroy because a network destroy requires a Photonview?