Unity-Technologies / EntityComponentSystemSamples

Other
7.09k stars 1.6k forks source link

Fix TargetingSystem.cs randomly skipping targets #278

Open cihanozcelik opened 10 months ago

cihanozcelik commented 10 months ago

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