I'm working on a multiplayer game but player seems like teleporting when server sends new position.
How can i make movement smooth? Here's my movement algorithm:
Server (running every 1000/60ms):
var updated = false;
var speed = 300/60;
if (this.player.cursors.up){
this.y -= speed;
updated = true;
}
if (this.player.cursors.down){
this.y += speed;
updated = true;
}
if (this.player.cursors.left){
this.x -= speed;
Way 1:
It's gonna be very difficult to prevent cheating if the client is authoritative about its state. You could limit some things like teleporting across the map, but it wouldn't be possible to detect things like teleporting a small distance.
Way 2:
This would definitely make cheating more difficult, at least in regard to movement. But it's more complicated to implement.
In the end it depends on the type of the game and what you want to achieve. If the game gets popular, it's bou