Download

Still a problem with acessing a child actor component's variables

Hi,

I am busy making some blueprints, but I still cant figure out how to access child component variables.
A simmilar problem (still unsolved) is described in this post here: https://forums.unrealengine.com/showthread.php?66359-How-to-access-child-components&highlight=access+child+actor+component

Now I have a simmilar situation and just cant figure out how to do it. :o

Lets say we have a blueprint with some public/editable variables like this one:

It has an integer called “FloorCount”, an enumerator for the column type and an actor variable, called “Datasource”

Child01.JPG

In the construction script, the BP reads from the Datasource and creates the fassade column as defined there.
The “FassadeTable” basically just holds the column description data.
That works out really good so far.

Now I want to make a Blueprint that creates a row of those columns.
It also has a variable to the “FassadeTable” datasource and a integer variable for the number of columns to create.

63392010f0b3c1eeda033425c4f15cc09c692fbb.jpeg

As you can see, the child components are properly spawned, but the column are not there.
That is because the child component’s “Datasource” field is still empty…

This is how the construction script for the FassadeRow Blueprint looks like:

ec16ceb86df9cf006043327673ee91cc50938972.jpeg

So now after I created the child actor component (of class type “FassadeColumn”), I cant figure out how to set its “Datasource” and “FloorCount” values…

If I pull out from the created actor output node, the menu doesnt offer me much:

RowConst02.jpg

When I disable the context sensitivity, I can choose between two “Datasource” elements.

b5ad4540936b9d48bfb3063746bc03ed04f6bb08.jpeg

The “default” one is the one of my TableRow script, so lets try the other one…

RowConst04.jpg

Nope, doesnt work. Neither does it work for the FloorCount…:frowning:

RowConst05.jpg

Soo. What am I doing wrong. How can I set the FloorCount, Columntype and Datasource for the child actors :confused:

Thanks for any help :slight_smile:

Cheers,
Klaus

Hello,
Your “return value” is a child actor component not your blueprint type. I haven’t try but i suppose that with a “cast to” your blueprint (with context sensitive uncheck) you would acces your variables.

well if it is one thing i have learned from many years of many similar programs(programs which will remain nameless) it is that you can use global variables to your advantage.

Thanks for your replies :slight_smile:

I thought the type is already set for the return value, since I picked the class in the details panel of the node. Thats why it says in the node “Actor Class Fassade Column”.
When I do a cast, it fails:

Cast01.jpg

So Im still not able to access the component’s variables :frowning:

What do you mean by “global” in this case? The level script?
I want to make this as self contained as possible. When I write code, I (almost) never use global variables.
Th Blueprints should be usable in any level without making changes to the level script.
The separation of the data and the blueprints with actors also serves anotehr purpose. By linking up a diferent FassadeTable instance to th Datasource property of the TableRow/Column you can easliy set up a different look, etc…

So any help is still welcome :slight_smile:

I just kept time to do tries and finally found : from return value : “get child actor” and from it “cast to” (I suppose because this is a component and you need the actor itself to have the “cast to” to work.)

Thanks for testing :slight_smile:
I tried it with the following results:

Cast02.jpg

If I choose the FassadeColumn Set Datasource node, it connects and the cast works…
(The Datasource getßnode is from the Datasource variable of this FassadeRow BP)

fe12763df0c9eea3624469ae569537ea3714a303.jpeg

But in the Editor, the columns are still invisible. So somehow the assignment doesnt seem to work… :frowning:

fb059a774220433471c34e80621761fb95e535b9.jpeg

Is there still a hidden catch that I may have missed? :confused:

Have you check your “datasource” variable reference value and be sure that it is filled with needed values when you set it ? You may try to set it on spawn / begin play in event graph instead of construction script to see if there is a difference.

The datasource of the FassadeRow BP instance does hold a reference to the FassadeTable BP.
The FassadeTable holds the correct data. All the single FassadeColumn BPs that you see in the background are also reading from it.

The FassadeRow assignment:
Editor2.jpg

Just as the FassadeColumn instances (which read the data correctly) :
Editor3.jpg

And the FassadeTable instance in the level:
1c6f3a3dd783e0616deafed83a07bf163729557a.jpeg

If anything would be wrong with the datatable, then the single columns would not build correctly (which they do).
Setting the value of the child component should trigger its construction script, right?

I maybe totally wrong but what i wonder is if the variable reference “datasource” from fassade row BP used here to set “datasource” from “cast to fassade column” has been set.
If i had to debug it for me, i would try a print string of values in this reference to check if it is ok or not or at least check and set manually variable in blueprint.
Then, if variable seems ok, i would try to set “datasource” in event graph instead of construction script.

Up until now I havent looked into the BP debugging options.
Tomorrow I will check and see if I can trace the values through execution…

Well, I set it in the details, just as for the single coumns (see screenshots). The instance of the FassadeTable BP in the level is also called “FassadeTable”…

How is that done? How do I get a reference to the FassadeTable instance?

To try to set datasource in event graph, create a variable of your child actor when you add it and use it in event graph to drag your “set datasource”

If you have check that both your variables are right set (with a key event print string " with datasource" values from variable and from childactor “datasource” in event graph) then is your actor component transform ok ? (i would try with a simple basic mesh in blueprint to confirm or a print string of a get transform / break get location / get scale in case of for some reason there is a modification) if location is wrong, it may be ok but in the wrong location.
If transform is ok then “add child actor component” is ok, “cast to” is ok, “get datasource” is ok, “set datasource” is ok. I would check the use of datasource in child actor blueprint.

@Fen
Thanks for the suggestions. :slight_smile:

I have now tried different approaches to see if the dtatsoirce reference in the FassadeRow script hold the correct data. i does.
When I create floor meshes directly in the FassadeRow BP, it works beautifully.

So, FassadeColumn BP work correctly if datasource is set.
FassadeRow datasource also works correctly. the Row could create individual floors from that.
Just the FassadeRow.Datasource to FassadeColumn.Datasource reference pasing wont…:frowning:

So Im pretty stuck with thisone :confused:

I know this is an old thread, but i was curios if you ever found out how to do this?
I have been looking for a solution to this a while now, but I havent found one, neither in BP or C ++
Using actors (blueprints) inside of actors (blueprints) and giving parameters to the inner actor at construction time seams to be a thing that definitly should work!
Your example makes perfectly sense to me, and i can think about a lot of other cases when this should be useful.

Yes, you can set the parameters if you spawn the inner actor, but that would have some drawbacks:

  • The inner actor will not be visible in the editor
  • The inner actor can’t be placed visually

Can someone (from Epic?) confirm that this is not possible in UE4?

Bumping because this is still an issue for me. No resolution whatsoever, weird that this isn’t more common.

I am running into this too - I am making a modular office set up and in my actor I have a child actor that has “number of drawer” options (a file cabinet) and in the BP editor I can set the number of drawers on the child actor - no problem - works great… but when I expose a variable for “File Cabinet Drawers” - and then in the set up of the File Cabinet - get the child actor - cast to file cabinet - set the number of drawers - I can SEE the execution happening as I want it to - but the file cabinet does not change

Screenshot 2016-12-13 09.23.30.png

Still seeing this problem here. Ejecting into the Editor while running the game and selecting the Child Actor immediately causes it to deselect itself. Almost like the object’s memory was released. Or maybe that’s just how it behaves since it’s now a component of the parent actor. Regardless, there is no clear instruction on how to properly use it IMO.

Figured it out on my end:

Get Child Actor from Actor Component

Cast Child Actor to Actor Class

Wrap a function around what you do with the updated value.
Create an event for setting that value, then call the function.

Call new event from Casted Actor and pass value.

Should work from there :slight_smile: Lemme know.