How do you instantiate a basic Object? (Not an Actor)

I’m adding the concept of Civilizations to my game and each player will select their own Civilization.

As far as implementation goes, I’d like to create a generic abstract Object called “CivilizationAbstract” and additional generic Objects that inherit “CivilizationAbstract” for each Civilization (like American, German, Korean, etc).

However, I haven’t found a way to instantiate/new-up these generic Objects. If I were to reparent them as children of Actor objects I think that would be overkill – they don’t need to be instantiated into the world/level and they don’t need Actor events.

Here’s some more details regarding the planned process that will be using these Civilization objects (in case this helps you understand what I’m trying to achieve).

  1. In GameMode, during event OnPostLogin: a Team struct is created and saved into an array stored in GameMode. This Team struct contains information like Team Color, Team Civilization (which is of type interface “ICivilization” which is implemented by “CivilizationAbstract”), Team Defeated, etc.
  2. In GameMode, during event OnPostLogin: after a Team struct is created, a COPY (different memory reference) of the struct is saved in PlayerState for the current PlayerController/PlayerPawn that is being created.
  3. At this point a master copy of the Team struct is in GameMode (server side only, that’s good). A copy of it is stored in PlayerState on the server and replicated to all clients.
  4. When a PlayerController creates a new Building or Military Unit, a copy of the Team struct (stored in PlayerController’s PlayerState) is saved inside of the Actor. This allows me to track which team owns which Actors in the world (this should support multiple people sharing the same team).

My final questions are: How can I instantiate a generic Object? If this is not possible, what would your recommended approach be to achieve this?

And for added clarity these Civilization objects will contain information about that Civ, like:

  • Icon(s)
  • Description
  • Civilization specific benefits i.e. one Civ might provide a military production cost discount for the duration of the game while another Civ might provide increased gather rates for certain resources.*

You can’t instantiate objects in blueprints, only in C++.

For your approach, consider using data tables for information about a civilization (unit types, balance, descriptions) inside your game mode or other such applicable class. I’m not sure you can use data tables for icons, but these are easily added as stand alone textures/materials that can be added to you UI later.

I never heard of data tables in UE4 (but I know what they are in other languages). Will do some research, thank you!

“Construct object from Class” would give you ability to instantiate objects in blueprints so you would be able to use them as data type.