Access Child Actor Variables in Constructor of Parent

Hello - I am trying to create an “Office Setup” blueprint - in this blueprint I want to have child actors such as a File Cabinet Actor - that File Cabinet Actor has options for how many drawers…

If I drop the child Actor into my Office Setup BP, I can change it’s number of drawers variable through the details panel - perfect… works great…

but I want to expose those options to the level designer - so he can drop in an Office Setup, choose how many drawers he wants for his file cabinet…

So what I’ve tried is - create a variable called “NumberOfDrawers” and I am trying to set the variable for the child actor (File Cabinet) in the Constructor of my main Office Setup Actor… and it does not work :frowning:

here’s my Blueprint of what I think should just work, you can see the execution flowing correctly - but the file cabinet does not change - even though if I set the variable in the details panel it all works …

I think the problem here is that at the time ConstructionScript is running the FileCabinet actors have not been spawned in yet. What if you execute SetTheFilingCabinets during the OfficeDeskSetup.BeginPlay event?

Thanks for the idea, but sadly there’s no change - the FileCabinets are already in the component list so I think the do already exist when this code fires - I could be wrong about that one, but moving the code to the begin play didn’t work, plus I wouldn’t want to have to have my level designer have to play the game to see what it would look like :slight_smile:

Could you provide a download link for your project so I can take a look?

Can you provide screenshots of the Spawn Actor From Class node where you are spawning the Office BP?

Sorry - no can do on either of those requests :slight_smile: I am not spawning the Office BP - I am dragging and dropping it into a level, and then setting some variables (like if it has a trash can, how many file cabinets, etc) everything works except the number of drawers thing - which is basically calling on the OnCreate of the FileCabinet, which is a Child Actor

Can you provide more screenshots with the surrounding code?

  1. Screenshot the code that is calling SetTheFilingCabinets
  2. Screenshot the code in the Filing Cabinet the uses the number of drawers variable.

Here’s the whole File Cabinet business - this is called directly from the on create of the Office SetUp BP

And this is the File Cabinet setting it’s drawers - which works fine if I just drop a file cabinet into the level

I am having this trouble with every child actor that I have - I cannot set variables in that child actor at all - are we only supposed to be able to go one level deep? kinda hurts the modularity of some things I wanted to build :confused:

I really think this is a bug, since the stuff is exposed to the details pane and available to change - just not via blueprint? seems like a bug…

Not messing with multiplayer yet - it’s got to do with everything being in the create event - as you say it’s probably bad design - so what I JUST tried was making a function in the child blueprint and moving the stuff into that - and calling it - seemed to work so far

I don’t think it’s a bug, it’s probably just a bad design approach you are taking.

It’s hard for me to provide you a solution without me being able to recreate this locally.

Any chance you can provide me some blueprints that I can import into one of the starter projects? You don’t have to send me your full project, but if you can send me a stripped down copy of your OfficeDeskBP and FileCabinetBP that would be extremely helpful.

Also in your OfficeDeskBP, is your FileCabinetCount and FileCabinet1DrawerCount both replicated variables?

Are you experiencing this issue only in multiplayer (with and without a dedicated server) and if so only on non-authority clients?

Are you experiencing this issue in single player as well?