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. 

BpFunctionLibrary Add Actor Component to Target

Hello UE community. Probably noob question, that was already discussed, but I'm done googling and trying/compiling on slow laptop. So, hoping for your help. Thanks in advance! So, I want Blueprint Function Library, actually containing only 1 function, to add Actor Components (not Scene Components) to Target's Actor. But when I call this function UE just crashes. So, what am I doing wrong? Thanks!

h: https://drive.google.com/file/d/0B-r94FRYXIpVLTBwRDB4YXRtb3c/view?usp=sharing

cpp: https://drive.google.com/file/d/0B-r94FRYXIpVcHo4NWxBSy1BOXc/view?usp=sharing

Product Version: UE 4.10
more ▼

asked Feb 28 '16 at 03:37 PM in C++ Programming

avatar image

1 2 3

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

1 answer: sort voted first

As a rule of thumb you should always check for pointers to be valid. At the start of the function I would do something like this:

 if(!IsValid(Component) || !IsValid(ToAdd))
     // Here you can also print an error to the log or handle the failure in some specific way

I would also check for valid reference after calling NewObject, so:

more ▼

answered Feb 28 '16 at 03:50 PM

avatar image

1k 38 13 61

avatar image Extermination Feb 28 '16 at 04:41 PM

Thanks for help! Don't know why I didn't do all this checking before...I strongly believed the problem is in creating component via NewObject. Anyways, the solution was pretty easy and silly. I just put in wrong component type in Blueprints, where i was testing it q_q

avatar image phoboz Feb 28 '16 at 05:13 PM

Glad it helped :)

(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