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"

Problems creating a callback from an ActorComponent to an Actor. Tried binding delegates as SharedPointers, and Raw. Also tried C++ function pointers, memory looks good

Hey, as the title says, I've tried creating a callback using UE4 delegates, however, before that I tried using a normal C++ function pointer. The memory is always valid when trying to execute the callback pointer, but it just won't run.

Vital declarations in my header

 typedef void(ATriggerActor::*VoidFuncPtrNoParams)(void);


 FOnCompletionCB OnCompletionCB;

Setting up the Callback

 void UTriggerOptionBase::SetUpCompletionCallback(ATriggerActor* CallbackOwner, VoidFuncPtrNoParams CallbackFunc)
 OnCompletionCB.BindRaw(CallbackOwner, CallbackFunc);

Trying to execute the delegate

 void UTriggerOptionProxy::StartTriggerOption()


  • UTriggerOptionProxy is derived from UTriggerOptionBase

  • I've tried binding the delegate with a shared pointer, same result.

  • Also tried doing the callback with a normal C++ func pointer, which oddly enough didn't work either. I tried to replicate the normal func pointer issue outside of an UE project, but I couldnt do it, it worked no matter how I threw it around.

  • The method I'm trying to execute is a private member method of UTriggerOptionProxy (UTriggerOptionBase), however, that shouldn't matter since I've got the proper access when I'm setting up the callback since I'm calling it from ATriggerActor::BeginPlay to UTriggerOptionProxy(UTriggerOptionBase)::SetUpCompletionCallback, thus getting proper access and memory.

If you want to see how I tried reproducing the function pointer issue outside of Unreal.

Any ideas? Would be greatly appreciated!

Product Version: UE 4.21
more ▼

asked Jan 20 '19 at 10:43 AM in C++ Programming

avatar image

6 2 1

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

1 answer: sort voted first

I solved this after some time, and now I feel even more stupid. First correction was to BindUObject instead of SP or Raw, which is an easy miss if you're new to UE4 delegates. However, after I fixed that I got another issue, and after some time I realised I hadn't included the TriggerActor anywhere, it was just forward declared, hence why it wasn't working ...

more ▼

answered Jan 20 '19 at 05:01 PM

avatar image

6 2 1

(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