When you press the keys, the character sets a velocity vector, which is transmitted to the server while the key is held down, a vector is added to the current position on the server, and a position is sent to the client, that is, the client will constantly receive the player position and the positions of other players on the server. Getting the position moves the objects accordingly. Speed vector 5 pixels. If less, it turns out too slow moving, but at 5 pixels you can see the twitching of the character, that is, jumps of 5 pixels. Accordingly, when you move a lot of traffic is used. I have a feeling that I did not approach the implementation correctly.
If you make a move similar to Diablo for example, then only click coordinates are transferred to the server, and the move itself is performed on the client, then it is synchronized. When doing this, management is much better.
My thought to improve this, for example, the speed vector, I make 10 pixels, I get the position where I should move (on the client), I move the character to the timer on the client by adding 1 pixel, as well as avatars from other players on the socket.
I would like to hear your suggestions on this topic.
Dug up just such an article http://www.ant-karlov.ru/PlayerIO-interpolyatsiya-ili-udivitelniy-mir-obmana.html And dug up such a source with interpolation
function getQuadraticBezierXYatT(startPt, controlPt, endPt, T) { var x = Math.pow(1 - T, 2) * startPt.x + 2 * (1 - T) * T * controlPt.x + Math.pow(T, 2) * endPt.x; var y = Math.pow(1 - T, 2) * startPt.y + 2 * (1 - T) * T * controlPt.y + Math.pow(T, 2) * endPt.y; return ({ x: x, y: y }); } http://jsfiddle.net/m1erickson/56sZj/ Looks like I’ve dug up the answer to my question, http://igamedeveloper.blogspot.com.by/2013/03/flash.html I ’ll leave the question open to someone else.
pixijstagpixijsyou entered? - Visman pm