Target multiple units with individual timers upon entering trigger

Hey, so I’m coding in c# and have an interesting problem I’m not sure how to tackle. I have a castle that units approach and once close enough attack. When the units are within attack range i want the castle to retaliate by shooting timed arrows at them. The trick is with each new enemy, a new timer has to start, and the new target shot at. Not sure how to approach this without possibly spawning something with each new unit, or perhaps putting the being attacked function on the unit themselves? I’d prefer a solution where I can have a function on the Castle that can just run parallel with each new unit, however I tried this with coroutines and had less than ideal results…

Any help is much appreciated!

Im not really sure what the probe,em is here but as others say, you could create a collection.

If you want access to a single float value associated with a game object use


If you want more data then create a struct type to use instead of the float.