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"

OnActorBeginOverlap.AddDynamic() Crashes on BeginPlay

Hi everyone, I've started doing some tests on a project and came up with a problem when trying to bind overlap events to an actor.

The setup: - I have a static mesh component that generates overlap events - I need to bind a function to the OnActorBeginOverlap (basically the container for the component)

I can obtain the desired outcome by using AddDynamic inside the constructor, however I've seen that if I try and use it from inside the BeginPlay this does not work at all and crashes the entire editor as soon as I hit play.

Now, given that there is already a solution to this (just put the code inside the constructor), could someone explain to me why the other method crashes everything?

This is where the line makes the editor crash. If I put it in the constructor everything works fine. alt text

Thanks in advance for the insight!

Product Version: UE 4.7
capture.png (44.4 kB)
more ▼

asked Jun 08 '15 at 09:07 AM in C++ Programming

avatar image

16 2 3 7

avatar image MickD777 Jun 08 '15 at 02:52 PM

Can you post the crash log? Sometimes it can be because OnNoteBeginOverlap is not a UFUNCTION()...

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

1 answer: sort voted first

I think I've found what it happens.

So, apparently the reason is that when adding a new event a check is made to make sure that the specific event being added is not already bound to the delegate.

alt text

The problem lies in the fact that it seems like if you bind the event in the constructor, this event will stay bound even after removing the line from the constructor and placing it in another function (eg. BeginPlay). The event will try to bind again, but will fail to do so.

I've found that if I delete the actual blueprint that inherits from the C++ base class and recreate it (kinda a pain to do since you have to reset so many variables sometimes) it usually fixes the problem. In that case all the events get unbound so that the single event can now be bound during BeginPlay.

Is this considered normal (should I unbind the event in a destructor?) or is it a bug?

capture.png (130.9 kB)
more ▼

answered Jun 08 '15 at 06:15 PM

avatar image

16 2 3 7

avatar image kamrann Jun 08 '15 at 06:27 PM

I had a very similar issue a while back, see my comment here. I believe this is an issue which needs looking into.

avatar image MickD777 Jun 08 '15 at 08:35 PM
 OnActorBeginOverlap.RemoveDynamic(this, &ANoteBase::OnNoteBeginOverlap);
     OnActorBeginOverlap.AddDynamic(this, &ANoteBase::OnNoteBeginOverlap);

This would always work I believe...a kind of workaround...

(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