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"

Office Holiday

Epic Games' offices will be on holiday from June 22nd to July 7th. During this period support will be limited. Our offices will reopen on Monday, July 8th. 

Spawn an actor from a specific string array

Hi there, so I have managed to make a system which takes in string values depending on what the player obtains. Is there any way to convert the string from the item i picked up, to a class which can be spawned in the world.

I have a main parent class which has loads of children, and i'm trying to make it so the child gets spawned if it is the first value in the string array, but i need it to be a class so i can plug that specific child in and make it spawn in the world.

Product Version: UE 4.22
Tags:
more ▼

asked May 01 '19 at 12:11 AM in Blueprint Scripting

avatar image

Jelloman1
6 1 1

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

2 answers: sort voted first

Here's an alternative that might be more suited to something that has grown in size and helps minimise complexity a wee bit:

alt text

My Object Map is String | Actor Soft Class Reference:

alt text

The only (?) downside is that it does not play nicely with variables exposed on spawn - but you can always fire a custom event after spawning the object.

capture.png (138.5 kB)
cap2.png (55.8 kB)
more ▼

answered May 01 '19 at 07:00 AM

avatar image

Everynone
14.6k 76 25 61

avatar image Nebula Games Inc May 01 '19 at 01:59 PM

That is much cleaner than my answer haha

avatar image Jelloman1 May 02 '19 at 11:30 PM

Thankyou very much, this worked a charm!

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

Yes, like this

alt text

more ▼

answered May 01 '19 at 03:42 AM

avatar image

Nebula Games Inc
5.4k 28 9 14

avatar image Nebula Games Inc May 01 '19 at 03:45 AM

Or you could have the switch set a "class reference" variable instead of directly spawning the actor class, then merge all the "switch on" outputs after they set the "actor class" variable into one "spawn actor from class" node and plug in the class variable.

avatar image Jelloman1 May 02 '19 at 11:31 PM

Thankyou, i'll try it!

avatar image Nebula Games Inc May 02 '19 at 11:33 PM

Haha, I think you have a better alternative above, but thanks anyway :)

(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