I decided to make a real time MMO game. instead of tcp I tried using socket.io for real time communication.
// Engine
setInterval(function(){
game.RunPhysics();
},5);
setInterval(function(){
game.SendUpdate();
},50);
after it worked on my router I uploaded the script on server and it was a disaster... atleast 1sec delay on sending and receiving! but when I asked my friends to play the game,few had no delay or lag what so ever. but some had delay and lag like me even though download speed was better... ping is 40-45 on everybody. I used socket io for unity.
Game.prototype.SendUpdate = function(first_argument) {
io.sockets.emit("update_signal", {"all": this.rigids});
io.sockets.emit("update_bullets_signal", {"bullets": this.bullets});
};
here i read I can do this:
var io = require('socket.io',{ rememberTransport: false, transports: ['WebSocket', 'Flash Socket', 'AJAX long-polling'] }).listen(port);
instead of
var io = require('socket.io').listen(port);
but I didnt have this option on unity(client).
Can I fix this?
via Avril Lavigne
No comments:
Post a Comment