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"

Blueprint Derived classes not respecting bound Delegates

Hello,

This is a semi follow up to my previous post here: https://answers.unrealengine.com/questions/673832/c-oncomponentendoverlap-never-called.html

I've managed to repo an issue with delegates when they are wrapped with a CDO flag check in the constructor e.g.

 if (!HasAnyFlags(RF_ClassDefaultObject))


If the object is C++ derived the delegates stay bound, however if you create a blueprint derived from the C++ class the same delegates are not bound upon play.

I'm not sure what the root cause of this is but I have attached a test project that I used to reproduce the problem.

Test Project

To test:

  • Compile project in either DebugGame Editor or Development Editor

  • Open TestMap

  • Press Play

  • "The delegate was called" should appear on the screen

  • Change the default pawn class to BP_TestPawn

  • Press Play

  • Nothing will happen

Expected Result: "The delegate was called" should appear on the screen.

If I remove the *RF_ClassDefaultObject*check the problem doesn't appear. Is this intentional behaviour? I figured you wouldn't want to bind delegates to the CDO?

If there is anything else you need from me, please do let me know.

Thanks!

Product Version: UE 4.17
Tags:
more ▼

asked Aug 29 '17 at 07:44 AM in Bug Reports

avatar image

Kanibel
131 5 15 19

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

1 answer: sort voted first

Hey Kanibel-

As long as the reference is self contained, binding a delegate to a class CDO is perfectly acceptable. If the constructor creates a component, attaches it, and binds something to it, then that should be fine (as you mentioned with removing the if statement). If it's trying to reach something externally, that probably needs to be done in another callback which would be called on the instance.

Cheers

Doug Wilson

more ▼

answered Aug 30 '17 at 07:39 PM

avatar image Kanibel Aug 30 '17 at 09:54 PM

Thanks Doug!

(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