Quantcast
Channel: Latest Questions by Wrymnn
Viewing all articles
Browse latest Browse all 131

Loop through partially filled Array of Objects

$
0
0
Hi I have game, it has many objects 500+, I store each created objects in this array and remove from array the objects that are destroyed. Now my Question is: How do I loop through this array/database? I need to activate/deactivate objects that are close/far enough from Player. (So also inactive objects has to get active later) The problem is ofc, the array will have holes like objectDatabase[5] = null but objectDatabase[7] = someObjectStored. If I make foreach loop, it will crash ofcourse. Any ideas please? (Don`t suggest object pooling pls it`s completely impractical for me)

Viewing all articles
Browse latest Browse all 131

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>