x

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 to add child actor from array in construction script?

Hi, I was wondering how I could get different bp actors (lets say some differen types of door Blueprints and different types of Pickup bp's) inside my construction script. The only way I got it to work so far is via drag and drop from the asset library in my construction script, I wonder how I would get them in via the actions menu in blueprint, also I would like to have them put in an array to choose them randomly afterwards, like I do it with "add static mesh" too. At the moment I am randomizing what child actor to choose with lots of branches and random bools in it, and via drag and drop catched child actors.... that feels uber wrong! :P

Any hints or links would be very appreciated!

Thanks

Product Version: Not Selected
Tags:
more ▼

asked Apr 04 '15 at 11:07 PM in Blueprint Scripting

avatar image

ardworx
26 3 6 9

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

2 answers: sort voted first

The array has to be "Exposed on spawn" and then you can asign the blueprint in the array slot from the editor in the details panel. note: The array has to be public( checkbox "editable").

Your array should be of type "class" and when chosing the random element select the class from the array and feed it into the spawn actor node.

Kind regards,

Eric

HyperReuts

more ▼

answered Apr 04 '15 at 11:21 PM

avatar image

ERuts
471 17 25 40

avatar image ardworx Apr 04 '15 at 11:40 PM

Hi Eric, Thanks for your fast reply! You mean like this? Cause this also does not work.. i think my Problem is even earlier in the process, I dont get the child actors inside my construction script, only via drag and drop. I tried object reference variable etc. But when i try to use the node "add child actor" it does not work, only the on drag and drop generated "add child actor" nodes work alt text

childactors.jpg (400.2 kB)
avatar image ERuts Apr 04 '15 at 11:52 PM

If you add a breakpoint at the branch, does it activates?

avatar image HAH Apr 04 '15 at 11:53 PM

I see you call "Get all Actors from Class"; but the actors don't exists yet, right? So wouldn't it make more sense to spawn the actors first?

avatar image ardworx Apr 05 '15 at 12:06 AM

Eric: I just noticed it works when I choose the actor in the drop down in the details panel. Thats awesome! I am one step closer :) alt text

BUT I would like to set it up from an array. when I Plug the exact same actor in the target slot of the add child actor node it does not work anymore. My Goal would be like described above choose some actors and make an array from them ( that allready works) and plug them into the add child actor node, but for some reason this does not work.

HAH: yes Problem is I dont know how to add random child actors from array.

childactors2.jpg (393.1 kB)
avatar image ERuts Apr 05 '15 at 12:12 AM

Generate random numer from lengt of array, from zero till the length of the array. Then use the array get node using the randomly generated index to select random child actor.

avatar image ardworx Apr 05 '15 at 12:20 AM

yes, Building the array works, the add child component node does not work anymore when i plug it in, evenwhen i plug in the same actor reference what i had choosen in the details drop down it stops working... nor as single object reference nor from array. alt text

childactors3.jpg (405.1 kB)
avatar image ERuts Apr 05 '15 at 12:25 AM

I do not see "Spawn" actor of class? What do you mean by not working anymore, it is not constructed to do something? The actor cannot have two parrent btw!

I see that there is no return value! The variables door and obstacle probably do not have an input. You should reference these or spawn and put them in these references.

avatar image ardworx Apr 05 '15 at 12:36 AM

Like i said, when i choose the actor in the drop down in the details panel (you can see it on the right in the attachment) it works as expected. So I thought in construction script this is the way to add my actors instead of "spawn actor from actor from class" I use spawn actor in event graph, but here in construction script there is no option for that. I need to find a way to change the class of the add child actor component node. alt text

childactors4.jpg (264.2 kB)
avatar image ERuts Apr 05 '15 at 12:41 AM

You can only spawn actors in constructionscript, not child actors.

Workarround: You can spawn a actor and attatch it to a child actor component

avatar image ardworx Apr 05 '15 at 12:53 AM

I think there is some terminology confusion here, like you can see in the last attachment, there is no "spawn actor" in construction script. And "add child actor component" works when the actor is selected in the "child actor class" drop down, the problem was that i cannot acces this in the graph... But I found a workaround, instead of putting references of actors in an array to put them randomly in the child actor class slot of the add child actor component node. I now just added a add child actor component node per object i want to add (or spawn ;)) and use a switch on int node to randomize it.alt text

childactors5.jpg (445.3 kB)
avatar image ERuts Apr 05 '15 at 12:55 AM

Happy that it works:)

avatar image vctr Aug 26 '15 at 06:02 PM

There is way to set class name from blueprint graph. Checkout this, it works for me alt text

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

In case anyone is still checking this thread, it definitely CAN be done. In my construction script I have an array of classes (Main Equipment C) which I want to become child actors. I add them using the a "ForLoop" and "Add Child Actor Component" node and then add the output of that node to an array of child actors (Main Equipment A), and immediately after "Set Child Actor Class" from my Array of classes.

alt text

Then in my event graph, when I need to trigger something on one of my child actors, I get it from my Main Equipment A array of child actors, and then "Get Child Actor" in order to get the reference I need to do it.

alt text

Hopefully this helps someone.

more ▼

answered Sep 14 '17 at 04:01 PM

avatar image

Benni.Lodge
28 2 7 7

(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