What’s the PROPER way to list objects on an object if I just want to check if it’s listed?

I’m wanting to do some experimenting with melee combat and I’m working on a system where I use multiple colliders spread out between the weapons previous and current frame to see the exact moment of contact between frames and to avoid hitting through walls, telescoping, and a plethora of other issues.

So my problem is this: If hit an object I want to put it in a list so that I can make sure and not double hit or do any unnecessary work on the CPU.

Is it fine to just add that object to a list or is there a smarter/cheaper way to do it?

Using a List<T> and checking if something exists already with .Contains is probably fine.

A more high-performance option could be using a HashSet if the intention is to have no duplicates: System.Collections.Generic.HashSet\<T> class - .NET | Microsoft Learn

1 Like

Instead of using triggers or colliders for the melee weapon you can just do a SphereCast to see if there’s anything ahead of the player when the sword is midway through its swing.

That won’t work for what I’m going for, but I appreciate the suggestion.