the Constructor Concept in Blueprints

Hi everyone,

see in different programming languages there is some common concepts like "Class " , but they also share another concept which is " Constructor " , So where is the concept of "Constructor " inside of Blueprints !!!???

if i would to make a guess i’d say probably the sequential Flow of actions between functions in any graph not just construction script ,or maybe just construction script itself (this one just because it has the Construct part in its name …hhh…).

Thank you.

So is that mean the constructor in C# is just the Construction script itself in Blueprints , though i can see that inside the construction script you have a purple entry node that has an execution wire just like any regular function you can create , so it means also that the construction script is just a function .

i’m confused a bit .

In C++ and BP, the concepts of “constructor” and “desctructor” are represented by 2 functions, called automatically at construction/destruction. That’s all.

Well what else is the constructor than a function, in any programming language? In BP you can set variable default values inside the variable config itself, the construction script is just the logic that is called whenever the object is constructed. Mind you, in UE4 / BP the object is constructed every time it is modified, so moving it around will call the construction script. The other catch is that, when you use play-in-editor the construction script will not be run (since the object is already constructed inside the editor) but when you play the game it will be run when the level is loaded.

I understand the fact that the construction script is executed once to build the object on start up, but if the construction script is a function why you don’t have the ability to call it ( i know things don’t make sense it’s just constructing the blueprint once it can’t be called whenever you want ) , but i want to know what makes it so special as a function.

I want to know the difference between situation 1 and 2 below :

1- i make a parent class of one of the static meshes from the selection i want in content browser and create its children then add them all into the blueprint class actor i want attached to as components …or else :

2- create blueprint actor class i want them attached to as components first and Let’s say doing it all in its “Construction script” by calling "add a StaticMeshComponent " then " Set StaticMesh " targeting the StaticMeshComponent to be whatever static meshes options from a selection depending on an index derived from “For loop” index ,and the static meshes fed into the selection options are chosen as i want from the content browser ? in this situation you can see there is no components attached in the componets panel upper left window (see picture below for the whole situation 2 )

The special thing about a constructor is that it only gets called once as soon as the blueprint is spawned. There’s nothing stopping you from creating your own function that is called in the construction script. This custom function could be called again.

There isn’t much difference in option 1 and 2 in regards to your example but the construction script can by used to create many usefully things that can’t be done very well with option 1. For example you could create a blueprint that contains a “Shipping Container” but using the construction script have it automatically set the colour of the “Shipping Container” depending on where it’s placed in the world. Manually having to change the colour via option 1 could become a lengthy task if you have a lot of them.

Thank you for your response , appreciated.

Ah…now i see so you telling me the functions called in the construction script could be representing a bunch of constructors similar to unity C# or so , and the role is to avoid repetition and automate tasks related to building the appearance of your blueprint and some functionality at the start .

So i took a look at your blog voxagon , how can i make pictures that are small in there ,what to do to see them much clearly cause i’ve opened them in new tab zoomed in but still some text like description do not appear clear , i see very interesting stuff in there .

The reason why i’m asking again is that your blog makes me feel you know the answer to what i was trying to do initially when i started this topic , please take a look at this situation while i’m diving into your blog to see what i can find , and if possible i need some advice on how to approach it ,thank you for your support , so the description of this situation is below :

let’s say i have a real life-like chess board , to represent it in UE4 :

1- along the Y axis will be Columns labeled by the letters a,b,c,d,e,f,g,h .

2- along the X axis will have Rows labeled by the numbers 1,2,3,4,5,6,7,8

Isn’t that similar to data table in ue4 …,???

in a real chess game with actual international rules they say i moved Queen to “h7” or “b4” ,so i want to be able to attach to each tile on the board the appropriate cross section name “h7” , “b4” and so , at the same time to be able to point at certain tiles relative to a specific tile,

let’s say i want the knight to move 2 tiles ahead and turn left or right in other meaning to be able to set the allowed moves for the chess pieces.

just tell me if it’s right or it’s a disaster and which better way i should take maybe a combination of Maps or structs or sets will do , so My plan is to :

1- create the struct called Columns concists of individual variables of type String or Name called a,b,c,d,e,f,g,h ( they are saying that names are faster to process i don’t know)

2- create a Data-table called “CrossSection” consisting of the struct called “Columns”

3- and the columns of the Data-table will be automatically the key names of the individual variables type String or Name ( a,b,c…,h) created inside the struct “Culumns”

4- then create rows named 1,2,3…8 which are the rows of the data table and set the variables values in the cross sections of the table to be respectively a1,b2,c3…f8,g7,h8 = those are variables type Name or String which i set in cross between each variable a,b,c,…h. and each row number (1,2,3…8) of the Data-table …

5- pull these values when needed in the construction script graph with the node "get Data-table row CrossSection " or create an array from them if i wish to represent each tile of the whole board .