The Daily Click ::. Forums ::. Klik Coding Help ::. Speed Calculation
 

Post Reply  Post Oekaki 
 

Posted By Message

Toni Montano



Registered
  13/10/2012 05:35:39
Points
  15
16th October, 2014 at 16/10/2014 19:47:48 -

Hi guys,

I would like to calculate peers speed. I recieve peer xy position at different time. Time depends on ping between me and peer so it could be between 20 and 500ms. Is it possible to calculate speed?

Thx for answers

 
n/a

Jenswa

Possibly Insane

Registered
  26/08/2002
Points
  2722
17th October, 2014 at 17/10/2014 18:55:25 -

Peer speed?

I am guessing you want to use ping time difference to calculate the speed of your object which was at (x,y) old and now is at (x,y) new?

Speed can be calculated by a division: distance / time.

You could create a new (x,y) pair which is the difference between old and new. That way you can calculate the distance the object has traveled. And divide this distance by the time (which was given by your ping) and you have the speed in pixels per milliseconds.

Is that something like you mentioned?

Cheers,
Jenswa

 
Image jenswa.neocities.org

Toni Montano



Registered
  13/10/2012 05:35:39
Points
  15
17th October, 2014 at 17/10/2014 21:11:32 -

Yes Jenswa,

i want to use ping time difference to calculate the speed of my object. I think you gave me very usefull information. I will try to do this. Only one more thing, what is the easiest way to calculate ping time beetwen me and peer?

Thx again for answer

 
n/a

Sketchy

Cornwall UK

Registered
  06/11/2004
Points
  1970

VIP MemberWeekly Picture Me This Round 43 Winner!Weekly Picture Me This Round 47 WinnerPicture Me This Round 49 Winner!
18th October, 2014 at 18/10/2014 03:59:04 -

You're better off just having the peers send their speeds & angles along with their positions.

 
n/a

Toni Montano



Registered
  13/10/2012 05:35:39
Points
  15
18th October, 2014 at 18/10/2014 08:16:08 -

I agree with you Sketchy,

but it seems that I don't understand how comunication between two computers (ping) work. I thought if ping between two computer is 200ms and on both computer "allways" blast X,y position that me and peer will "allways" recieve new x,y position, just 200ms later. But it seems to me that I recieve x,y position from peer every 200ms and not allways.

Which thing is correct 1. or 2.?
1. ping 200ms - x,y position from peer is "allways" blasted to me - I recieve x,y position "allways" just 200ms later.
2. ping 200ms - x,y position from peer is "allways" blasted to me - I recieve x,y position every 200ms.

Thx for the answer

 
n/a

Sketchy

Cornwall UK

Registered
  06/11/2004
Points
  1970

VIP MemberWeekly Picture Me This Round 43 Winner!Weekly Picture Me This Round 47 WinnerPicture Me This Round 49 Winner!
18th October, 2014 at 18/10/2014 19:28:26 -

To be honest, I don't know, but it doesn't matter anyway.
I know that if you "blast" rather than "send", the messages aren't guaranteed to arrive in order or even at all, so maybe that has something to do with it (blasting is still the right thing to do though, because it's faster).

Also, don't "Always" send the position. Ideally, you should only be sending information when there is a change in input. For example, when a player presses an arrow key, send a message to peers; when the key is released, send another message. There's no need to send anything in between - you can just assume the arrow key is still being pressed.

 
n/a
   

Post Reply



 



Advertisement

Worth A Click