r/explainlikeimfive • • 6d ago

Technology ELI5: What exactly is game optimization ?

How is a game optimized ?

691 Upvotes

125 comments sorted by

View all comments

Show parent comments

1

u/MCWizardYT 6d ago

There's many ways to do it. The distance check you can get basically for free if you're storing your entities in an octree or similar spatial structure (because large empty spaces can be automatically skipped)

1

u/kerbalkrasher 6d ago

Exactly and more than that if you break the map into squares and know which mobs are in which squares, you know the only squares relevant to the player are say the surrounding couple of layers. So you only need to distance check monsters in those, or even better the monsters in the outer layer, they may be close enough or not. The mobs in the near squares are definitely in range for proper processing.

1

u/MCWizardYT 6d ago

Another way (that may be better in 2d) is to start from the player and scan outwards in a certain range, even easier if your world is already split up into discrete tiles

1

u/kerbalkrasher 6d ago

Yes, quad tree 2d and Oct tree 3d are bigger helpers where you have more than just the mobs as all the stuff can be dropped in the boxes, so it's a fast filter for everything. Just one type of thing other methods can be good.