I got it!
After trying for a while, I think i finally fixed online. Before I was sending the raw coordinates and setting them but that was making my collision/camera system behave weirdly. After trying many things, I tried to code it in a way that it uses the inputs and the coordinates.
So, now the game in online takes the inputs and calculates the new coordinates and collision. And to avoid desyncs because if i only use inputs, It WILL desync at some point, so i used the distance form:
√((x1 − x2)2 + (y1 − y2)^2)
(y2 != y *2 it means the 2nd and first x/y)
By using the distance formula, I can now calculate the distance between the players accross the different devices. Which means that i can use the inputs when the characters are slightly desynced and when they are desynced a lot, I can just straight up use the coordinates.
I also have to fix the gui because i had forgotten that the player also needs to put in the ip of the host. Because of that online doesn’t work accross different devices right now. To fix that I’ll have to use a module such as the pygame gui module or fix it myself with pygame. I’m leaning more towards doing myself because I don’t really want to learn the pygame gui module and imo it should take less time if i do it myself.
Comments 0
No comments yet. Be the first!
Sign in to join the conversation.