Can I add a class to a list on collide rather than game object?

I am attempting to create a list of NPC class when my player collider hits them. I am able to make a list of game objects, but I am having trouble interacting with the variables. Is there a way to create the list of NPC’s rather than game objects? Or access the NPC variables within the game objects?

List NPCs = new List;

This is create an empty list of NPC classes.

When you collide with an NPC, you can do something like the following,

Assuming the gameobject you are colliding with is named other…

NPCs.Add(Other.GetComponent();

It is also a good idea to make sure the object you collided with actually has an NPC class attached to it, or this code will generate a null reference error.

Hope this helps,
-Larry