Download

Can i create an Actor class using c++ templates?

Hello, i’m trying to define a class FInventoryTable to hold a table of items for my inventory. I would like to be able to specify which type of items that class supports using a c++ template so i can do something like this:

FInventoryTable<class AItem> Inventory; // Holds all types of items
FInventoryTable<class AAmmoItem> AmmoZone; // Holds only ammo items

I can this in pure C++, the problem is that if i want to replicate this information i can’t, because this class does not derive from a Unreal Engine class like AActor. Is there a way to pull this off or i have to get rid of the c++ template and check the type at runtime? Thank you.