Objects of the same class not found equal

I’m working on a game that requires RTS style building placement. Currently I have it set so that left clicking will spawn an actor of a set class at your cursor location. I want a key that will delete the actor under your cursor’s location and set the int tracking the amount of a certain building to be restored. Right now what I have is a line trace, when it hits an actor it gets the class of the object and checks it against a “Contains Item” Node with an array of all the building classes. For some reason it never returns true even when I’m certain the objects are the same. Why does placing an object change it’s class and how can I fix it?

EDIT: I tried using the Class is Child of Node. It also registered false.

Sorry if I wasn’t clear in the original post. You have a set amount of each building. I want to check the class in order to increase the amount of that specific building by 1.

you could have the overridden delete function in each class call a function in the GameState before its deleted. it can pass its own class type in as a property of that function, or it can pass a name or an integer ID representing the building type.

I think I found the issue, I’m comparing an object class to an actor class. Is it possible to get the actor class when I hit an actor?

i don’t know, but i would just make a BuildingType property in the base class, and use the pointer to the actor to ask it to return its ID. knowing what class something is doesn’t seem very object oriented or polymorphic.

what if, later in development, you wanted 2 classes to be on the same list. something like a burn ward and a cyborg repair center both counting towards the hospital quota. if you make their type a property that can be set, like an enum or ID number, then you could make many different classes count as the same type of building.

In pokemon, each item was stored in a different inventory list depending on what kind of item it was, but they didn’t have to check what class the item was, because each item has a property called pocket, which determined the inventory it belonged to.

List of items by index number (Generation IV) - Bulbapedia, the community-driven Pokémon encyclopedia)

I figured out a work around. I just have the blocks sending an event on destroyed instead of checking the hit from the destroying raytrace.