it's my first time creating a multiplayer game but i am aware of much things that are a no-go in network communication. But i am not sure depending coordinate transfer between the clients.
I am currently writing a 2D Multiplayer game where you can drive and shoot with small tanks.
Now i am not exactly sure on how to realize the movement.
I thought of two methods where i try to avoid one of em...
1: In OnUpdate() when updating the Tanks location, send the new position to server, server will then send the position to all other clients.
Cons: High traffic and it might lag for other clients...
2: If player starts moving, it sends one packet to server that indicates the player started moving. Server then sends one packet to all other clients indicating that the player started moving. Movement packet may contain the speed of the player then.
Pros: Very efficient (low traffic) and impossible to do speedhacks/teleport hacks.
I definately prefer method 2 and already tried to implement it. It works actually, players are updating its locations but i am having issues with the speeds.
Locally in onUpdate() i update the Tanks location with the following code:
TankTransform.Pos += Vector2.FromAngleLength(tankTransform.Angle, Velocity * Time.TimeMult);
Velocity is for testing purposes constantly 5f.
Remote clients will update the remote tanks with the same method, but speeds do not behave same like on local client.
How can i fix this? I thought Time.TimeMult is frame-independant?
Thats what my current problem is, and yeah, movement works actually just fine like this except with that little Speed issue.
I hope someone can help me.
Thanks in advance.