Hi all,
I have been struggling to achieve an efficient algorithm for finding the nearest entity of a certain type to an entity or player in the same surface. I am aware that a function already exists for finding the nearest enemy to a player in the game and that it is quite optimized, I need something equivalent to this. Does anyone have a working algorithm that fits this criteria or could perhaps point me in the right direction? Again, my appologies if this is in the wrong forum.
Kind Regards,
Simcra
Algorithm for finding nearest entity
Re: Algorithm for finding nearest entity
The internal data structures for entities aren't setup for a "find nearest of type" - you'd just have to find all and iterate checking distance - which is inefficient at best and horribly slow at worse due to all the extra memory allocations of finding entities and pushing references into the lua state.
If you want to get ahold of me I'm almost always on Discord.
Re: Algorithm for finding nearest entity
That's sad, I'm guessing it's not worth feature requesting this?