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"

Passing a class into a function (Blueprint)

I have a blueprint function that runs on the server and spawns AI of the class type that I specify. I have several more specific class types that all live under a parent AI parent class.

I want to be able to pass in the more specific class type (not the parent) into the function so that once inside I can call just one "Spawn AI From Class" and feed that class in. I don't want to have a mess of a Spawn AI From Class node for each individual class.

Is this possible? And if so, how do I accomplish it.


Product Version: UE 4.21
more ▼

asked Feb 04 '19 at 08:50 PM in Blueprint Scripting

avatar image


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

1 answer: sort voted first

Ofcorse it is, all types you seen in color pins can be set as variables and arguments in function, including the class. You can do that by searching participle base class of classes you want to pass in variable type selection, and once you find it click it and you have option to either use object or class type or asset version of it.So pick the class (purple one).

more ▼

answered Feb 05 '19 at 12:08 AM

avatar image

37.8k 937 172 1123

avatar image FlexNSB Feb 05 '19 at 01:04 PM

Thanks for your quick response.

Are you saying that if my input parameter is set to the parent-class and then I change the type to class type, that I can pass in the child-classes and the class reference will remain as the child-class?

To use a more visual approach :

Parent Class is 1 Child Classes are 1a, 1b, 1c

If I set the input parameter as class 1, and change type to class reference, can I pass in 1a and have 1a be what is seen inside the function? Or does 1a get cast to 1 when I do that?

If so, this is exactly what I need.



(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