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"

Cannot call Actor Add Component inside Function Library

I made a function library and a method, the input is an Actor type variable, and when I drag off this variable, I can't use any Add Component method.

alt text

When I do the same in normal blueprint class graph, there's of course no problem.

alt text

Product Version: UE 4.9
more ▼

asked Nov 17 '15 at 09:33 AM in Bug Reports

avatar image

230 8 18 25

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

1 answer: sort voted first


This is expected behavior. The reason that you cannot add a component inside of a function library is because the Add Component nodes store a template upon creation, and in the function library there is nowhere for this template to be stored.

more ▼

answered Nov 17 '15 at 07:18 PM

avatar image

Sean L ♦♦ STAFF
43.5k 485 152 442

avatar image marsonmao Nov 18 '15 at 08:39 AM

Hi, thanks for the reply, could you please explain "store a template upon creation"? Thanks.

avatar image Sean L ♦♦ STAFF Nov 18 '15 at 01:53 PM

This means that when the Add Component node is created, it will store a template for whatever type of component you are adding. In the case of a function library, there is not a place for the component template to be stored, which is the reason that you are unable to use that node inside of a function library. Hope that helps.

avatar image marsonmao Nov 19 '15 at 04:47 AM

@Sean Flint, Ok, I'd like to know more about what "a template" is, is that some kind of an object? Or maybe you can give me some hint where I should read in the engine source codes, like what files and what line numbers or function names, thanks!

avatar image Sean L ♦♦ STAFF Nov 19 '15 at 01:48 PM

A template in this context is just a basic framework for the component that you'd like to create. It's not technically an object, as much as it is something that is stored "behind the scenes", so to speak.

avatar image marsonmao Nov 20 '15 at 02:25 AM

Yeah I know it's behind the scenes, but as I read the source code, I can't figure out the whole design, so I'd like to get some hints. At least for the source code for the good friend of AddComponent(), DestroyComponent(), it's obviously that can be called only by the owner Actor, but I can't see any reason why it should not be called in a function library. I can just change a few codes so that DestroyComponent() can work in function library, it can be done, but I dont know the concern of the original design.

avatar image marsonmao Nov 20 '15 at 02:26 AM

Or, to make the question simple, will it be implemented in a future release? (I mean to be able to use Add/Destroy Component in a function library).Or, is it impossible to be implemented?

avatar image Sean L ♦♦ STAFF Nov 20 '15 at 01:55 PM

This feature is working by design, which means it will not be changed in a future release. If you'd like to make changes to the source code, you are welcome to do so.

(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