C++ Custom BP Node: Delay execution pulse?

I’ve got a question about how custom C++ nodes work and exactly what I can do with them…

So, let’s say I’m writing a custom C++ blueprint node to handle dialogue in an RPG. Is it possible to have it essentially “delay” or “pause” execution of the blueprint graph until, say, the player presses a button (so basically the node emits an execution pulse after a button is pressed)? If so, how is this done? I can’t seem to find much information on writing custom BP nodes at all, unfortunately.

Also, apologies if this is in the wrong section. I didn’t know whether to put it in the C++ section or the BP section, but I figured it had more to do with C++ coding than blueprint.

This can already be done without going through the hassle of creating a custom K2 node.

You’ll have to consider the problem differently. What is “pausing” here if not simply executing something on a key event? When you reach the point at which you want to “pause”, just set some bool variable, then branch on that bool on your key event to “resume”.

The reason behind having a custom node is that I think it would simplify dialogue creation. Sure, I can branch on a boolean, but having to branch on a boolean for every dialogue node is surely going to become very tedious very quickly. Not to mention what I’d have to do to introduce branching dialogue…
Thus, the reason behind having a custom node. It’d be fantastic if I could just create a bunch of dialogue nodes, hook them up to each other, and have them just work ™, you know what I mean?

Ah, that’s true. FWIW, there seems to be some dialogue classes in the engine but it seems rather embryonic, I don’t think it’s ready for use.

What you’re looking for is latent Blueprint functions (identified by the “Latent” metadata keyword, look at UKismetSystemLibrary::****Delay). A macro can do what you want, actually, using said Delay node:

Being latent, the Delay node doesn’t hold up execution and yields whenever it’s encountered. It’ll keep looping until you feed something to the Continue exec pin, whether it be from a button press, a UI widget, etc. It’s a bit tacky but it’s easier than rolling out your own K2 node.

I am kinda surprised there isn’t already something in the engine for it, but looking at the few nodes tagged Latent doesn’t show anything of the sort. If you wanted to avoid the tacky delay, you could probably create your own node based on Delay, using a new kind of FPendingLatentAction that fires based on execution input instead of a timer.

Hm. So if I could find the source code for that Delay node, it might be exactly what I’m looking for?
Particularly if I can do that with multiple outputs. I could easily envision a branching dialogue node with one output per dialogue option, which would make designing branching dialogue for an NPC practically brain-dead simple.

Thanks for the pointer, I’ll have to look into that.

Delay is declared in UKismetSystemLibrary, but also check out MoveComponentTo in there as well. Have a look at the C++ implementation to see how to do your action and register it with the latent action manager.

RE: Multiple outputs, you can designate enum parameters (one input or one output) as ExpandEnumAsExecs in the function metadata, which will cause it to generate multiple exec pins based on the value of the enum (output) or that set the value of the enum (input).

Michael Noland

usefull, i’ll try