Search the Community
Showing results for tags 'movment'.
Found 2 results
So I have a game, where movement and collision are big aspects. Currently I have a system where when a client say presses "W", body.velocity of their sprite is set to +150 in the x plane. Previously, my system for the multiplayer side of the game in terms of movement was when the player moves on the client side, send his new x & y position to the server. This was a great system, until I started turning the server into an authoritative one to prevent against hackers who could speed hack and set their own positions. My new system is whenever a player hits "W" send to the server that this person is hitting W and then server calculates the players position (say adding 4 pixels for every W call to the players last position) and saves it on the server side. (Basically movement is on the server now). Now this is where it gets a bit hairy. Since I dont wait to get a response back form the server to move the player on the client side (bc that would cause terrible ping issues), whenever the player hits W, his REAL position (on the server) is calculated and saved to send to other players, and his "client position" the one that could potentially be hacked to move faster or teleport other places, is also moved just so i dont have to deal with ping issues. P.S This position is useless, it can be hacked or changed all it wants lol. Now this new system leads me to the following problem. The issue with this new system is whenever i set the velocity of the client sided sprite, its speed doesn't correlate with the server, since on the server I have to move the player based on if they are hitting a key or not, and there is no way for me to know how long they are holding the key, I cant use velocity on the server, only say moving the persons position 4 pixels every call of "W". However if i say switch to this system on the client, of setting a position 4 pixels away everytime they press W, instead of changing the velocity, I can sync up the client and server position perfectly. Butttt this creates the problem that my sprite can no longer collide with things because it is teleporting everywhere essentially. So Im stuck lol. Anyone have any ideas of how to handle this? Is there possibly a way i could do collision without velocity being set? Thanks for any help and sorry for poor language and bad grammar lol. Im insanely tired and just want some sleep rn