Looping a custom event

Hello, I have this custom event I made that plays and displays audio and text from an array of Dialogue that I have.


I currently have it that every time the player presses the Interact Button, it calls the function. Therefore, the player can press interact to go through each line of the dialogue.

I’m wondering how I can make the event loop without the player pressing interact… So it just calls “Cycle through dialogue” until the array reaches a certain number but the player only presses interact once at the beginning.

I’m not sure if it’s a simple answer but I tried using a For Loop, and a Do N node… Is there a simpler way to do this that I’m missing?

Hey @malak03s!

You will need to get the length of your audio and set a re-triggerable delay node based on that float time, and then increment your Dialogue Index and call “CycleThroughDialogue” again after the re-triggerable delay.

Let us know how it goes of if you could use more help! :slight_smile:

Would I have to do re-triggerable delay for every single audio in the array or is there a way to have it calculate whatever sound is currently playing from the array and calculate the length of that only?

I don’t know exactly how you’re doing this, but handed this with no additional context I’m thinking:

Pull off of "CycleThroughDialogue"s Dialogue Sounds array, use GET and pass in the index as well, then pull off of THAT and try Get Duration? if you can do that, you can pass it into a retriggerable delay’s duration variable to make it match the length of the sound.

1 Like

Sounds perfect! Thanks so much for your help! :slight_smile: I’ll make sure to let you know if it works, hopefully! Might be a bit of a wait but I’ll make sure to let you know!

1 Like

Timer option

2 Likes

Hi! Just to let you know, that did work! My only problem now is that I liked the functionality of having the player interacting have the ability to skip the dialogue and move onto the next one and I’m not sure how to implement it now!

Interesting, that should have allowed you to keep the option of skipping dialogue as well as adding the timed continuation. Also, Rev0verDrive’s timer solution is perfectly viable.

Can you show what you have in code at this point?

Get back to us and let’s get it solved! :slight_smile:

Yes, I can show my code, so this is now the event in my parent blueprint:

and this is me calling it every time the user presses the interact button in the child blueprint:

My main problem now is that If I let a few of them play out, but decide to skip some of the long lines, for example, sometimes it goes back a line then continues. Or, if I let the whole thing play out, and it stops, so I press “Interact” again just to finish the “cutscene,” it sometimes goes back to the second line or so.

Overall, I’m sure there’s a more efficient way of doing it than I’ve done but I’m just not sure how…

The other solution I got on here seems viable, but considering I’ve never done anything this complex on Unreal before, I’m just not entirely sure how or where to implement it. Sorry if this is all overcomplicating it a bit! I’ve never worked enough with Unreal to have to develop a dialogue system.

If there’s an entirely better way to achieve what I’m trying to achieve, just let me know! Thanks!

I think it’s an issue around the incrementing of the integer.

Logically what’s happening is the ++ is only happening AFTER the dialogue completes when the button is not pressed. If the retriggerable delay is not waited through, it does not increment.

Also, the increment node does not actively save the number to the variable, it is a temporary amount, so you need to then SET the variable directly after the increment, so when it is called outside of the event you get the new saved number. I marked the spot where to move the ++ and then SET the Dialogue Index variable. Moving that you should also be able to get rid of the ++ and Delay after the Cycle Through Dialogue event on the button press, the natural moving through and the button press will use the same ++ node. That seems to be the Bird Dialogue Index here.

There is a problem there though- this seems hard to reuse throughout other blueprints due to the dialogue being set up only for one actor (bird).

1 Like

@Mind-Brain

1 Like

Well I have a “dialogue index” for all my other blueprints as well. In each blueprint I plug the “objectDialogueIndex” into the “Dialogue Index” of the “Cycle Through Dialogue” event. I’ll give it a shot and let you know anyway!

1 Like

I’m trying to follow this but I’m finding it hard to figure out how I can apply this to an event that can be called into different blueprints that all have different dialogueSounds arrays