Hello, I'm making this post because I'm a bit stumped right now. I have this what I thought was a simple scenario: My player needs a reference to all shootable targets in an area around himself. This is used by my aim assist system to select the aim target. Now what I had first way just a list of all targets that are part of the fight and I literally loop over all of them each frame and make a few checks. Beginning with the distance to the player. This works for few Targets pretty well, but I thought it would be cleaner to only check Targets close enough in the first place, instead of all.
Now I was thinking of using OnTriggerEnter and Exit Methods to cache a list of all Targets inside the AimAssistRange. But this leaves me with some problems. Disabled (Pooled) or destroyed or even Enabled enemies won't cause the OnTriggerExit Method to fire. So I've been thinking of many different ways to "patch this hole up" but they all seem annoying in some way. Like I don't want my targets to have a reference to the aim assist of the player, so they can register themselves. But I also don't want a list of all targets in the aim assist, so it can subscribe to all targets' OnDisable and OnEnable events.
I feel like there must be another clean way to handle this. I would appreciate any tips on this.