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"

How to pass function pointer of FTimeline.PlayFromStart

I'm quite new to C++ programming in UE4 and I just can't get the gist of this error. So a big part of my game logic is based on this DoOnce node from bp look-alike function. For starters, I tried to make it pretty general for maybe later reuse during development. Here's the plain logic of it:

 //an alias for a function that returns void and has no parameters
 using DoOnceFunc = void(*)();
 //the DoOnce function that works with an optional parameter of type DoOnceFunc
 void DoOnce(DoOnceFunc Func = 0) {
     static bool bDo = true;//initial state of the DoOnce
     if (Func != 0 && bDo) {
 // if a func is pass in the optional parameter the bDo is checked and if both true the func is cold
         bDo = false;//the purpose of the DoOnce is reached
     else if(Func == 0) {
 //otherwise is no function is pass by the optional parameter it means that the user desires to reset the DoOnce
         bDo = true;

In simple Visual Studio project it all worked pretty smoothly. Now I want to implement it in my character class. I read through Rama's Function Pointers article and followed through with the code: - in the character.h:

typedef void (AMain_Chr::*FunctionPtrType)(void); void DoOnce(FunctionPtrType Func = 0); - in the character.cpp:

void AMain_Chr::DoOnce(FunctionPtrType Func = 0) { static bool bDo = true; if (Func != 0 && bDo) { (this->*Func)(); bDo = false; } else if (Func == 0) { bDo = true; } } And only portion of code where i use it is in an if statement where I check if character is standing still or not:

 if (RLMovementInputFlag == 0) {
         GetCharacterMovement()->MaxWalkSpeed = 600;
         SprintBlend = 0;
     else { DoOnce(AMain_Chr::LerpLagCam.PlayFromStart); }

The function passed in DoOnce() is a FTimeline.PlayFromStart. The error I get are: - error C3867: 'FTimeline::PlayFromStart': non-standard syntax; use '&' to create a pointer to member - error C2572: 'AMain_Chr::DoOnce': redefinition of default argument: parameter 1 - note: see declaration of 'AMr_Clappy_Hands::DoOnce'

I don't really understand the first error as I have also tried and pass in the function DoOnce(&AMain_Chr::LerpLagCam.PlayFromStart); or using the parameter void DoOnce(FunctionPtrType& Func = 0); even though it really doesn't make sens. The second error I'm sure it has to do with me setting default value on the func parameter with 0 it being a pointer but default setting it with nullptr doesn't work either. Having a default to the func is kind of the big point of the function without whitch it wouldn't work right. The third error kind of gets on my nerve. I tried using the UFUNCTION() macro and the following error was spit back: Error: Unrecognized type 'FunctionPtrType' - type must be a UCLASS, USTRUCT or UENUM. I'm 99% sure it's one of my newbish mistakes but I lost way to much time tinkering it. Plz kindly help. Oh, and also is there a tutorial for making a good function library? Sorry for bad english.

Product Version: UE 4.14
more ▼

asked Jan 04 '17 at 03:29 AM in C++ Programming

avatar image

1 1

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

0 answers: sort voted first
Be the first one to answer this question
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