Don't Be Me (A Cautionary Tale about 'OnBegin')

By now you’ve all learned three things about Verse: (1) everything is error-checked-to-death so that the code will just keep running even if there are issues and (2) You end up making a lot of different creative devices and (3) people tend to cram a lot of code into ‘OnBegin.’

Well, I learned the hard way that there is no particular order (that I can determine) that the various creative devices initialize. In one device I made a HUD that would be used by another device, and I put in a test function in device 2 to make sure that the HUD from device 1 was updating.

It wouldn’t update! I spent hours putting in print statements to see where the issue was and there was a ‘map’ to HUD elements that just wasn’t working. Was my syntax wrong? Did Epic change something? I had no clue.

Then I put print statements before the function call and the function initialization and, of course, the function was being called before the ‘widget[actor] map’ for the HUD was being initialized. I cannot recall ever having this error before with any other language, but live and learn.

Don’t be me. Don’t assume initialization order of devices!

3 Likes

Good tip!

1 Like

I often put Sleeps in my OnBegin so I “know” which one will trigger first, if it can help :person_shrugging:

1 Like

Makes sense. :+1:

The funny thing was that my function and my function call were both fine. I just tested it inappropriately in an ‘InBegin’. In its intended location (in the game) it was perfect.