question

m-j-e-s-s-e avatar image
m-j-e-s-s-e asked

[UnrealEngine] Variable not updated in between Events.

Hello all,

Hopefully this is a simple clarification. I'm using PlayFab/Unreal 5.1, if that helps. Also assume that all this is taking place in the event graph.

I'm working on setting up a client UI that allows players to connect to a matchmaking server to place players in a game. All has been going well, but I noticed the player could spam the matchmaking/cancel buttons to error the system out.

I have an initial button that starts the process of obtaining a matchmaking ticket. When the server responds to the ticket creation, it sets a timer to retrieve the status of that ticket.

And I also have a cancel button that is displayed after, the cancel button just sends a request to the server to cancel all matchmaking tickets for this player, and also invalidates the timer set in the matchmaking button.

But I noticed if you click the cancel button immediately after clicking the matchmaking button, the matchmaking ticket wouldn't have finished its creation. Once the ticket is finished, since it doesn't know the cancel button was hit, it queues up the ticket checking mechanism.

I figured I could just set an overall "LookingForMatch" that would be a final authority during events like these, should we continue the matchmaking process or abort it where we're at.

The problem I've encountered, is that the boolean/variable update to accomplish this, doesn't appear to be actually updating during the matchmaking ticket process, even if a new event happens, it's still reading the old value. All of these events are connected via delegates as you would anticipate.

I've validated with logging that the correct order of ops appears to be taking place. This makes me think the event chain I've set up won't actually see variable updates until after it's completed, but I can't find any documentation confirming this (I could be overlooking something of course).

Can someone explain the error in my process?

I figured this is more of an UE forum question, but my account is under moderator review there... (for 8 days :D). Given that, I figured I'd ask here to see if anyone knows!

unreal
1 comment
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

m-j-e-s-s-e avatar image m-j-e-s-s-e commented ·

I can validate a simple case works, I can see the variable update in between timer events that aren't connected to the PlayFab CreateMatchmakingTicket call.

0 Likes 0 ·

1 Answer

·
m-j-e-s-s-e avatar image
m-j-e-s-s-e answered

I resolved this by changing my thought process on the interaction.

Rather viewing the button clicks as a synchronous event, which is easy to abuse, even accidentally. I started to view the buttons as a player's way to signal intent and viewing matchmaking as a separate engine outside of the players intent.

I set an automated timer; every tick we try to take the appropriate actions based on the system at the time.

If a player clicked cancel, the next tick would try to cancel any actions that cause the player to go into a match. If the ticket was in the creation process, and finished during this tick, then we would just catch it in the next tick.

I find this solution to solve a number of edge cases.

If you have alternative opinions/solutions, I'm always open. But this resolves my concern.

1 comment
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Neils Shi avatar image Neils Shi commented ·

I'm glad you solved it, feel free to let me know if there are any other questions.

1 Like 1 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.