Why cant we use delay() from KismetSystemLibrary in c++? Whats the mistery behind it?

I need to make a costum wait in my behavior tree depending on what attack my bot will do, or in death i need to know if some event could happen and 4 days ago i´ve started to search for a latent fuction like delay in BP, but for some reason all the posts in forums or questions in anwswershub tell that we can´t and should never use the delay function.
That’s really wierd since we can call it from the kismetSystemLibrary, and use it in BP, i’ve tried to setup the FLatenActionInfo, but that doesnt seem to work in c++.
First question, is there a way to use that fuction in c++?
If yes, can someone post a simple exemple?
If not, why not, what´s the reason behind it?
And finally, how can i do a latent fuction? If anybody knows how to do it, please post a simple exemple, please…

My exemple, that does not work.

Thanks everyone. :wink:

You’re supposed to use Timers in C++. IIRC you can’t use it because the Kismet library is MINIMAL_API, so it’s functions aren’t exported.

Delays aren’t really as efficient/manageable anyway.

But its possible to use a fuction like printString(i´ve tested an it works) from that library, but not delay… Ok, so all the libraries that are MINIMAL_API, are limited in c++, and some functions simple can not be used in c++, is that right?

I need to create a latent function because in this case (And other cases in my AI bot):


I need to be able to say how much time it will take to do the next thing in the behavior tree. How can i setup a latent function (a simple exemple will really help me out)?
PS I know how to setup timers, but they dont work in that case.

There is already a built-in behavior tree task for what you want.


I know that there is a wait node, but you can not change the value of that node within a running game.
In this image that i´ve uploaded, you can see that i´ve made a costum wait, that changes its value with the needed time within other functions in other blueprint, i want to be able to do that in c++, cause i cannot show that gamelogic in blueprint in my final presentation to my teacher.
If anyone knows how to do a latent function, please show a little exemple.

There is no delay in C++??? there should be an alternative…

In any case you can well if is homework I cant say more :stuck_out_tongue: than this… hint: tick

thought dont know if that solves the problem of “not having delay”.

Unhappely theres not a solution since bttask dont have a tick fuction.
It would be really nice if Epic staff could do a tutorial on how to do a costum delay function that does work with c++.

Basically anything that’s MINIMAL_API can’t be used in an exported game (unless it’s used in Blueprint through a node or something), but C++ can’t use those functions at all usually since they’re not exported for the compiler to Link against.

BT Tasks do have a tick, its just not called Tick. I believe its called TickTask? You can see the overrides in a blueprint task and just add the correct one. ExecuteTask starts a Task, TickTask updates it, AbortTask ends it prematurely (or Tick returns a fail/success result).

Have a look at BTTask_MoveTo.h as an example in /Source/Runtime/AIModule/BehaviorTree/Tasks/ for the C++ versions.

Delay is latent function.
The long story short there is some magic behind scenes, which create proxy objects, which are reponsible for keeping state of delay (or any other).

You can’t use it in C++, because latent blueprint functions are very specific to how blueprint works.

It’s the same why you don’t have state keyword in C++, though you can achieve state machine in many different ways.

What are you essentialy asking is using timer, tick or manually created proxy object, which will make callbacks to the object, which created it.