Networked Object Pooling Questions
Hello! I'm new to Normcore, & I'm trying to get my bearings in terms of adapting our current Object Pooling system for Normcore. I'll introduce the problem and my primary questions, and attach my current script.
I've created a script called RealtimeObjectPool which implements the interface IRealtimePrefabInstantiateDelegate. I have a few questions, some about design and some more technical.
I've attached my code as a picture since not enough characters remaining. Thanks in advance!!
I've created a script called RealtimeObjectPool which implements the interface IRealtimePrefabInstantiateDelegate. I have a few questions, some about design and some more technical.
- I have a CreateObjectPool() function that runs when a room is created. This creates the object pool on all clients independently. -- The first problem, or question, I have is... I'm assuming I should use the Realtime.Instantiate() to spawn the pool objects right? Given that they are prefabs with realtime views, and the console gets mad at me if I use the regular Unity Instantiate(). But I'm unsure how to smoothly handle that. Should I have the Host only call Realtime.Instantiate() in CreateObjectPool() instead? But if so, how do I hook the spawned list of pooled objects to the client? Need some guidance on best practice there.
- Outside of the pool, if I have a manager request a pooled object, should I do a call to Pool.Instance.InstantiateRealtimePrefab()? Or is it the case that, since the delegate is implemented in a script on the same Object as the realtime component, I simply need to call Realtime.Instantiate() from a manager and Realtime will automatically use my custom implementation instead of the default spawning?
I've attached my code as a picture since not enough characters remaining. Thanks in advance!!
