DEV Community

Maiu
Maiu

Posted on

1

#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.

Image of AssemblyAI

Automatic Speech Recognition with AssemblyAI

Experience near-human accuracy, low-latency performance, and advanced Speech AI capabilities with AssemblyAI's Speech-to-Text API. Sign up today and get $50 in API credit. No credit card required.

Try the API

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Explore a sea of insights with this enlightening post, highly esteemed within the nurturing DEV Community. Coders of all stripes are invited to participate and contribute to our shared knowledge.

Expressing gratitude with a simple "thank you" can make a big impact. Leave your thanks in the comments!

On DEV, exchanging ideas smooths our way and strengthens our community bonds. Found this useful? A quick note of thanks to the author can mean a lot.

Okay