I’m building a game where each device just compares a variable with another device and the winner is declared by the user with the highest number. What is the best way to achieve this? All the multiplayer tutorials I seem to find are on movement.
If using UNET, I’d call a command on each client while passing the value. When both values are received on the server (even if the server is a host running one of the clients), you compare the two values on the server and declare the winner. After the server declares the winner it informs both clients, which can be done through rpc or syncvar.
Another option would be for each client to send a command to the server to update a syncvar on their own player object. Then each client waits for both syncvars to update, and then the clients can themselves figure out the winner (because both clients actually have copies of both player objects, with updated syncvars, so each client now has both values available).
A 3rd option is this is an easy situation to just handle the whole thing with UNET messages for everything. Both clients send messages to the server, and server responds with the winner by sending messages to both clients.