- Home /
Object pool - how to load stuff
Hi
I have an endless runner type game in progress for mobiles(android/iOS). I have a working object pool setup, and I'm not sure how to load my environment objects on run-time.
One way would be to replace all environment items with a "marker", add a collider to it, and load the proper object in run time, when the player bumps into the "marker". Downside: lots of colliders, and physics.
Other would be, to always check the distance between the player and the marker, and when the player gets close enough, it would load the proper object.
Or should I just save the info into a csv file and parse it in runtime via distance checks? Without any marker/placeholder gameobjects?
Any other alternatives maybe?
Answer by whydoidoit · Mar 24, 2014 at 12:22 PM
You could lay it all out in a scene and then use an editor script to create your csv file for you. I'd seriously avoid the collision detection to activate stuff and go with a distance to the object, though using sqrMagnitude is higher performing. Perhaps if you treated your CSV as a linked list in order of the objects you approached you would only have to check a single object at a time.
yeah the manual distance check is ofc faster than physics. Also..does occlusion culling make sense in a scenario like this, when I already pool everything?
yep, I switched everything over to ordered lists, and performance went sky high :) thanks