Help with random array, please

Hi guys! I’m working on a bar tending project. I’m trying to get random drink orders to show up on a widget. I have my text array stored on a game instance. I basically want one order to show up randomly, then once it is completed a new order will show up in the same space. I haven’t started working on the actual conditions yet, just the array. At the moment all the array are displayed rapidly one after the other.

1 Like

Function binding executes every frame. So you’re Casting and generating 60 (or more!) times per second. It’s neat when you do want to update property often. Not here, though.

I’m trying to get random drink orders to show up on a widget. I basically want one order to show up randomly, then once it is completed a new order will show up in the same space.

Sounds like this should be done with a callable Custom Event instead:

  • remove binding and flag the text block as variable:

image

  • call a custom event to update the text:

image

You could cast to the GI or, which is quite often a better idea, generate random text inside the GI and have it update the widget:

  • in the widget:

image

  • in the game instance:

image

Send ready generated text to the widget.

thanks for the help. i followed ur method but i can’t seem to connect the custom event. Do you know what i might be doing wrong?

The Game Instance is not a text widget. You’re doing something very different from what was suggested. Note that the custom event is in the widget BP. The GI would just call it.

You can cast to the GI, as you were, it will work. Just avoidng doing it inside a function bound to a text field. Do note we know nothing about the structure of the your script. Hard to suggest something tangible that fits right into it.