EntityComponentSystemSamples icon indicating copy to clipboard operation
EntityComponentSystemSamples copied to clipboard

Fix TargetingSystem.cs randomly skipping targets

Open cihanozcelik opened this issue 1 year ago • 0 comments

The GetEntriesInRangeWithHeap method is called with unfilteredChunkIndex as the first parameter. This parameter is intended to be an entity index within kdQuery, to ensure the algorithm does not find the entity that is performing the search. However, in this sample, the seeker entities are not included in kdQuery, so there is no need to skip any entity. Passing unfilteredChunkIndex seems arbitrary here, and we could instead pass -1 as a quick fix for the sample:

Tree.GetEntriesInRangeWithHeap(-1, transforms[i].Position, float.MaxValue, ref Scratch.Neighbours);

Related Issue: #275

cihanozcelik avatar Nov 08 '23 14:11 cihanozcelik