Hello, I am trying to make a multiplayer game where a client can send their x and y position to other clients in the match. To test, I tried to send the coordinates (0, 0) first.
Here is the code I use to send data.
let data = {x: 0, y: 0}
socket.sendMatchState(matchID, OpCodes.position, data);
I connected another client to the same match and it received the data successfully, however, when I am trying to access the data variable I get a uint8array, not the original data object {x: 0, y: 0}.
Here is the code for the listener:
socket.onmatchdata = (result) => {
switch (result.op_code) {
case OpCodes.position: {
console.log(result);
movePlayer(result.presence.user_id, result.data);
}
break;
}
}
When I console log the result object, here is what is displayed:
Is there any way to get the coordinates sent by the original client? Thanks!