Announcement

Collapse
No announcement yet.

Restriction on setting Child Actor Component variables

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Restriction on setting Child Actor Component variables

    Hi, I've started developing a game in UE4 which takes place in a grid-based maze, and initially I tried to do this by using a "Wall" blueprint to generate a section of wall occupying a single cell within the grid. The blueprint exposed 4 boolean variables that indicated whether there were walls north, south, east and west of the cell, and used their values within the construction script to select the correct mesh and place it at the correct orientation (for example, if there were walls to the north and south, a mesh representing a straight section of wall was generated). The blueprint worked beautifully by itself, but then I scrapped it in the end as I couldn't use it within my containing "Maze" blueprint (I could use "Add Child Actor Component" to add a "Wall", but I couldn't set the 4 variables to what they needed to be).

    Last night, I found a way to set these 4 variables by using the "Add Child Actor Component" node's return value, and feeding it through a "Get Child Actor" node followed by a casting node to get the "Wall" instance, which I could then call "Set ..." from. However, whilst the blueprint compiled and the game ran, the walls were still being generated using their default variable values (false for all 4 variables, which produced a "column" section of wall). After thinking about it, I think I have a theory that kinda makes sense, but I just want to confirm that it's correct...

    So, although I didn't have time to test this, I'm guessing that using the above-mentioned method DOES actually set the variable within my "Wall" actor; the reason why it didn't work as expected is because setting the variables using this method doesn't trigger the construction script to be executed again (like it does in the editor). Basically, the construction script only runs at the "Add Child Actor Component" node, and doesn't re-trigger at a "Set ..." node.

    Please can somebody confirm whether my theory is correct or not?
Working...
X