#Creating 2d multiplayer board game with mirror

10 messages · Page 1 of 1 (latest)

minor fern
#

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.

split island
# minor fern Hi, i am trying to understand how the mirror works, i am making simple 2d game 4...

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.

split island
sly yew
minor fern
minor fern
split island
split island
minor fern
split island