Archived

This topic is now archived and is closed to further replies.

AndersO

Updating position/velocity over the network

Recommended Posts

AndersO    140
Hello all. I''m having troubles with updating positions/velocitys over the network. The idea is to calculate positions locally at the client and then send it to the server wich then send it to the other clients. This is how I calculate the position locally (the usual equations): position+=velocity*time + 0.5*thrust*time*time; velocity+=thrust*time; Now, sending the position is straightforward, the velocity is not. The ''time'' in above equations is the time it took to render/update a frame, so its going to be different on different computers depending on how fast it is. So I need to "take out" the frametime dependancy from the velocity I guess. I tried to send this instead: velocity_to_send=velocity/time; And then on the receiving clients multiply by their local frametime. But that didn''t really work so good as I thought it would. The velocity gets wrong and I cant understand why. Oh yea, I need to send the velocity because of the prediction on the clients ofcourse. So any ideas?

Share this post


Link to post
Share on other sites
evilchicken    122
competely seperate the your rendering from your logic code.

are you trying to do extrapolation? if so I recommend sync''in all the clients to the server time and going from there.

ie
xpos = xpos + xvel * time_spent_traveling_over_net;


do a search, this forum has lots of good topics about sync''in.

Share this post


Link to post
Share on other sites