Hi, i am trying to understand how the mirror works, i am making simple 2d game 4 x 4 grid, on clicking the cell the color should be changed, it should be reflected to the server as well as to all clients. i have used Synch var hooked to function which is working fine only if i change my cell color value from server, its reflected to all client correctly, but as soon as i press the cell, i change the color value of the same synch variable, but value is not changing. Pardon me for silly question but its my second day of learning mirror. please help.
#Creating 2d multiplayer board game with mirror
10 messages · Page 1 of 1 (latest)
The function you pass to the "hook" function performs a color-changing operation. However, this function already calls the "hook" function after the color-changing process. In this case, the function has a recursive structure, which is an incorrect usage.
In this scenario, using "command" is a correct approach because the color change will be handled on the server due to the "syncvar" feature. However, the function you pass to the "hook" should not perform the color-changing operation again. It should only execute whatever needs to be done after the color has changed.
Additionally, there is no need for "command" to be a function since you can already manage the color change on the server. The "hook" function is the structure you should use if you want to perform an action on other clients after a color change.
And sending a message to 2 channels is a bit rude 🙂 I did it once too, I was embarrassed when I realized it.
Suggest carefully going through the MultipleMatches example...it's a Tic-Tac-Toe game which is similar to what you're doing.
apologies, i thought i was asking in wrong forum.
thanks for helping. i had resolved the problem yesterday by couple of hit and tries. One more thing i want to clarify. i want to run this on my mobile build, is there any way i can make server on computer and user can player throught mobile as a client ?
You can start a server on your computer and access the server via mobile using the tunnel method. I think this would be a quick solution. Of course, if you're asking for testing
Or you can access it directly by adjusting the firewall settings on the network you are connected to. I don't have very detailed information.
thank you. i will try to follow the method you suggested. I never did anything related to tunnel method/firewall settings before.
It transfers your connection over a different connection, allowing clients to access the connection via a different route.