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"

SpawnActor with variables?

I need to Spawn a Actor while also defining the variables so already the construction script does things based on those parameters. How can I do that?

Furthermore I like to just pass all the variable parameters from the parent BP to the spawned Child BP. Basically I have tree branch BP with lots of parameters which can spawn a smaller child branch which should have the same parameter settings.

Product Version: UE 4.8
Tags:
more ▼

asked Aug 04 '15 at 12:47 PM in Using UE4

avatar image

Davision
945 104 147 201

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

1 answer: sort voted first

Hi Davision.

You can set any variable in a BP actor with an "Expose on Spawn" flag (in the details panel when the variable is selected in the BP editor) which will add a pin for a value to pass into it when using the SpawnActorFromClass node. Make sure you set the variable(s) "Editable" as well. The construction script will now have access to that value from the start.

As far as passing variable parameters from parent class to child class, that should already happen automatically as part of normal inheritance. The child will take on the default values of the parent. If they need to be changed in the child (i.e. have some non-default value) you can simply pass that in by making the variable exposed on spawn as above.

more ▼

answered Aug 04 '15 at 01:29 PM

avatar image

Xenome
2.1k 64 54 120

avatar image Davision Aug 04 '15 at 01:54 PM

Thanks!

But with the passing of all parameters I mean the parameters that I set in the BP settings of the actor placed in the world, so that are not the default values I need to take over. Do I have to do that then manually for each variable/parameter with Expose to Spawn? Would be just more convenient to just pass all parameters instead of making that for like 20 variables.

avatar image Xenome Aug 04 '15 at 02:45 PM

In that case, you could, for example, expose an actor reference variable as well, to which you send the actor whose values you want to copy for the newly spawned one. Haven't tried anything like that in a construction script per se, but I don't see any reason for it to fail, assuming you give it a valid reference to a predecessor, so to speak, that already exists in the world. You would still have to get all the values and write them to the correct place in the new actor of course. Could be made easier if the parameters were in an array for example, then you could simply copy the whole array in one go.

avatar image Davision Aug 04 '15 at 04:44 PM

Thanks, will give it a shot.

avatar image emperor_katax Nov 06 '17 at 11:22 AM

... you saved me with this ..... thanks !! ..... it works perfect ! ... I`m spawning characters on the stage and need to give them a unique ID at the spawn time .... I thou to figure it out by Event thou, but this, I mean your guide, is the key ... : ) ,,,

(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