Closed nerdachse closed 1 year ago
hi, thanks for the interest in the crate.
Since everything involved in a tree is generic over the component you use for tagging, you should be able to just add a second tree alongside. be aware that this will impact performance.
I will admit that while theoretically possible, i haven't tested that usecase.
I'm planning on working some more on this crate over the next few weeks(vacation+work slowing down), updating it to 0.10 and reworking the internals (should be minimal API breakage) so i can make sure to add a example of this usecase during this time.
closing for old
Hello!
First off: awesome work, thanks a bunch for this crate!
I am using it, among other things, for simplest AI behaviour:
NPCs should attack some structures or players based on distance.
Towers should only attack NPCs, not players.
I am using
k_nearest_neighbour
to grab a few NPCs to attack. The problem is, that multiple players could be nearer and then no NPC is attacked, because all spatials are tagged with the same component.Now one solution would be to have multiple components or rather multiple trees for different types of entities so that one queries only the ones we are interested in. Visually that's like having red and blue dots but completely disregarding one color for some queries and the other for others.
I am well aware that I can also use
within_distance
and then iterate over all entities within that radius and filter out the ones I am not interested in.But I may have a lot of towers and a lot of NPCs plus other entities like items so a lot of unnecessary iterations and comparisons.
I hope my example is clear. I am open for any hints and solutions.