Adam's Lair Forum

game development and casual madness
It is currently 2017/04/28, 10:16

All times are UTC + 1 hour [ DST ]




Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: 2016/05/11, 21:39 
Novice Member
Novice Member

Joined: 2016/05/06, 14:33
Posts: 16
Role: Hobbyist
Hi,

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.


Top
 Profile  
 
PostPosted: 2016/05/11, 23:00 
Novice Member
Novice Member

Joined: 2016/05/06, 14:33
Posts: 16
Role: Hobbyist
OMG,

NEVER F****N MIND.

I am so stupid, i had changed the speed of my local player in the Editor to a higher value.
Now i reset it and it works perfectly!

Also, the described method 2 is very nice and works perfectly.
Once i did some more efficiency testing i will report you guys back here.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC + 1 hour [ DST ]


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group