Skip to main content
gamedev.net
🔒 Locked

changing data?

Started by MrShmoo 0 replies 500+ views
Original Post
MrShmoo
MrShmoo
ok..continuing saga of newbie programmers... we got variable packet size working (packing and unpacking from a char[] structure using memcpy)...but we have a really strange situation. the client sends a float array of size 3 (its position) to the server...the server receives/unpacks the data fine. then when it comes time to send the data back to the client...the client receives and unpacks the data fine. however, when we try to update the client''s data (i.e. if the server detects a collision it tells the client not to move even if the client wants to move) the client''s data changes on a small scale. e.g. we can receive it into xPos and zPos print out xPos and zPos and everything is fine and constant if the client is not moving but if we receive xPos and zPos and put it in client->xPos and client->zPos the data values will alternate between say .1234 and .1534 any ideas? (we''ve tried just regular assignment and trying to memcpy the values in)
cbenoi1
cbenoi1
> ... the client''s data changes on
> a small scale

I''m assuming here that since the network protocol seems to be working fine (a round-trip of non-moving data induces no errors), then your problem seems to stem from the conversion of some kind of world units into floating point numbers from your collision detection & position correction routine.

Using floating point numbers induces imprecisions; that''s why games use integer math to define the world units. It''s like moving a sand puddle from one place to another; you always pick up some dirt along the way and after X number of moves, your pristine sand looks more like dirt... I suggest you read the following excellent article about the math of multiplayer games (including a discussion on defining and using world units):

http://www.gamasutra.com/features/19970829/obrien_01.htm

-cb

PS: Moving your thread to the "Math and Physics" forum is likely to yield a better response rate.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.