The Photon Forum
is Closed Permanently.
After many dedicated years of service, we have made the decision to retire our Forum and switch to read-only: we´ve saved the best to last! Your search result can be found below. Plus, we offer support via these channels:
Try Our
Documentation
Please check if you can find an answer in our extensive documentation on Fusion.
Join Us
on Discord
Meet and talk to our staff and the entire Photon-Community via Discord.
Read More on
Stack Overflow
Find more information on Stack Overflow (for Circle members only).
Object Pooler Implementation
OmerSim
2022-09-04 00:49:45
Hello,
I am having hard time to figure a very simple thing -
How to modify my single player object pooler code, into the one using Fusion's native object pooler for enabling/disabling game objects for all clients without destroying and instantiating.
I've looked into the docs for some time but it's unclear to me and it seems I'm breaking my head around a very simple manner.
I am attaching my original, non-network object pooler script, I would highly appreciate if you can help me transit this into a Fusion object pooler.
Here's the code I am using:
protected virtual void InitializePool()
{
for (int i = 0; i < poolSize; i++)
{
GameObject obj;
obj = Instantiate(objectToPool, this.transform);
obj.SetActive(false);
objectsPool.Add(obj);
}
}
public virtual GameObject PoolObject()
{
for (int i = 0; i < objectsPool.Count; i++)
{
if (objectsPool[i].activeInHierarchy == false)
{
objectsPool[i].SetActive(true);
return objectsPool[i];
}
}
Thanks in advance,
Omer
Comments
First, you need to create a class
Then, replace the default pool that fusion already has with this one, as suggested in this link.
https://doc.photonengine.com/en-us/fusion/current/manual/network-object/network-object-pool
Back to top