Designing a round counter device in UEFN

Hello! I have been working on a round counter device because I need to know in my project when I reached a certain round or not. However, I am still new to verse programming and I don’t know how to use the OnRoundEnded event of the End game device in order to determine when to increment or not.

Thank you in advance for any help provided

I can’t give you the necessary code, but perhaps a pointer in the right direction: Everything resets after each round, including all of your devices, i.e., they get set up “fresh” again, running their OnBegin methods and so on. Thus, to my knowledge, your devices have no way to store information from previous rounds. The only way around this is to use global variables via a weak_map for the session. Hopefully this hint can get you close to your goal, although I think weak_map’s are quite a bit more cumbersome to work with (and thus less beginner-friendly), as you need to instantiate new objects rather than just setting variables. I might submit a code snippet later with an example for how to do this, if so, I’ll link to it here. In the meantime, the guide on Using Persistable Data In Verse is very good. Best of luck!

1 Like

I forgot this piece of information, as stated on the page I linked to above, regarding a weak_map(session, t): “Data is only stored during the current session and does not persist across subsequent rounds”. Perhaps you could save round-information in a persistent weak_map(player, t), but it would be quite a hack, and probably rather error-prone.

I would recommend building your own round system, that does not rely on an End Game Device to “actually” end the round. You could teleport players to their starting positions, display current scores etc. at the end of the “round”, and make it seem like an actual end-of-round. Of course, it is quite a bit of extra work, compared to just ending the round, but I think this is the better option for now. If this is your first game, consider skipping the rounds element for now if at all possible, as it does complicate matters.

1 Like

Thank you very much for you help of the matter. Moreover, I apologize for the late answers as I was pretty busy the previous days. Again, thanks a lot, have a great day!

Yes, I also thought about this idea and it might the easiest and most possible one. Thank you for the recommendation.