HI, i’m playng around with some kind of a turn based simple game.
Here’s the project
Player 1 press A key, playcanvas send a message to the server (smth like Player 1 is going to attack Player 2). The server responds, and the turn starts. Player 1 moves to the player 2, attacks it and then moves back.
Now i want to tell the server, the turn is ended. I have a solution, but i think it’s a bit “dirty”.
When the attacking player gets back to his own spot, i’m going to set his state to smth like “completed”. After that i’m going to call Network script function endTurn where i will check which player has “completed” state. If the player.id equals to the Network.id, i’ll send ‘endTurn’ message to the server.
I think it’s quite complicated for a such simple task.
Of course i can just send a message from endTurn function of Netwrok script without determination which player just ended his turn. But in a result all the players will send the ‘endTurn’ message to the server.
Could anyone help me to figure out a clean and beaty solution for this task?
PS. I’ve just thinking about one more solution. When the players get back to its own spot, i set his state to “completed”.
In Network update function i’m going to check if this.player has “completed” state and the send endTurn message.
Still i don’t like the way of adding any if logic to Network.update function, cuz it’s called every frame and i think it can screw my application performance.