Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

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.*

Product Version: UE 4.13
more ▼

asked Sep 12 '16 at 12:09 AM in Blueprint Scripting

avatar image

694 24 24 55

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

2 answers: sort voted first

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

more ▼

answered Sep 12 '16 at 07:29 AM

avatar image

1.2k 57 21 58

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

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.

more ▼

answered Sep 12 '16 at 01:42 AM

avatar image

420 32 9 27

avatar image elitereloaded Sep 12 '16 at 01:50 AM

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

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question