DEV Community

Maiu
Maiu

Posted on

#babylonjs Browser MMORPG #indiegamedev Ep21 - Spatial Hash Grid Area of Interest

Hello
I'm working on POC (prove of concept) implementation of monsters system. I managed to achieve first milestone which is loading entities into engine.
And finally i have occasion to show You how my hash grid area of interest is working.
Engine is refreshing area of interest data each second and it sends info to the clients to show/remove entity. There're two visibility ranges. First is lower (eg 50 units) it describes distance below which entity should be visible and second visibility range (eg 100 units) is bigger and it's use to hide entities. This way I'm avoiding sending create/remove entity command when some entity is on the edge of visibility and potentially I'd have to show/hide and resend entity each spatial hash grid update.

Keep in mind that it's not working on radius but on bounding boxes (rectangles) and entities visibility is not symmetrical. This implementation is far more efficient and actually not having it symmetrical doesn't change anything. Eventually I'll setup it to comfortable range and players will no care about it.

Top comments (0)