1
votes

I'm trying to create a real-time 3d multiplayer game that should update all connected players' movement every frame.

So far, I used socket.io for sharing data between players but other players look kind of skippy and not smooth when they move.

I basically use socket.emit() to send my movement(position, rotation) data to the server and then the server sends back all other players' movement data using client.emit().

Will the performance improve if I use WebRTC's RTCDataChannel instead which allows the P2P communication between players?

1
No it wouldn't, I had this issue with my game, if this is happening while you are locally hosting it then the server logic is slow (i.e. you may have nested for loops or other things decreasing performance). On the other hand, if this is happening while in production, then it may be a latency issue which would require interpolation. Here's an article on interpolation in games . I found this site really helpful for these kinds of situations gabrielgambetta.com/client-server-game-architecture.htmlAmeer
@Ameer Thank you for your answer. but can WebRTC be faster since it is P2P and I can use UDP to send the data?Zack Lee
It could be faster, but you have to consider the security risk involved in p2p communication, users could alter the data being sent or send malicious dataAmeer

1 Answers

1
votes

An RTCDataChannel setup for unreliable communication (UDP) will be faster than socket.io (TCP) since dropped packets do not need to be waited for. There are no additional security risks.