- Home /
[Solved]Pooling activate lag spike
I'm using advanced pooling system free plugins for unity which seem simple but basically doing a 'unlimited runner' where i pool sections with traps ad such in a prefab, seems it the pooling system works fine, but for some reason im getting big lag spike when enabled a section even with a few objects inside maybe 200verts each only, lag can be up to a seconds on mobile but still noticeable on pc which shouldnt be there, not using unity pro*
poolingSystem.InstantiateAPS(pipeToSpawn.name);
even if i manually enable a section in game there's also lag so any ideas why this would occur for, not many models, low verts, on a good pc, basic shaders(only 25 draw calls in that area) :/ also disabled all script that might have cause problems
[Edit] :/ just realized i've been getting this error
NullReferenceException: Object reference not set to an instance of an object PoolingSystem.InstantiateAPS (System.String itemType, Vector3 itemPosition, Quaternion itemRotation) (at Assets/Plugins/PoolingSystem.cs:111) Player.Update () (at Assets/GalacticCollector/Scripts/Player.js:174)
thats my full spawn bit:
var pipeToSpawn : GameObject = pipe[(Random.Range(0,pipe.Length))];
pipeSpawner = poolingSystem.InstantiateAPS(pipeToSpawn.name, Vector3(0,0,pipePosition+50), Quaternion.identity);
pipePosition += 400;
The null reference error will definitely cause a lag spike. Errors are slow due to taking a stack trace.
yea i know, just fixed it though, had to send gameObject as well for some reason, and also big lag spike from using mesh collider on a 200 vertsices model? so just changed to box collider, less accurate but works alright
Did your mesh collider have a rigid body? $$anonymous$$oving colliders without a rigid body can be expensive.
nope, no rigidbodies, dont u mean with its expensive with rigidbodies?
Answer by Kiwasi · Nov 28, 2014 at 06:06 AM
No. The physics engine assumes colliders without a rigid body never move. It does some batching that makes them faster. But when you move them the whole batching has to be redone.
Try adding a rigid body set to kinematic and see what happens.
interesting, seems ok, so ur saying anything with a collider that moves around should have a kinematic rigidbody on it, and static objects dont need it. Same goes with box colliders i assume?
Your answer
Follow this Question
Related Questions
Grabbing an object from array 0 Answers
Object pooling - SetActive not working 0 Answers