Hi all.
I'm createing an pure physics LAN game, where the central thing is the environment. You're able to interact with it. But the problem is the LAN part. I can't get the physics to work right when several people are connected (even though I only played with one friend it got screwed up). The boxes and everything just jump around, and that's quite annoying. Can anyone please help me with how to make Dark Physics work with multiplayer (I'm using the tempest plugin, just so you know)?
In-game subrutine:
inGame:
rem Receive multiplayer data
while TGetMessage()
RNetwork()
endwhile
rem THE PLAYER
rem Mana
gosub updateMana
rem Chat or not...
if chater = 0
gosub player
else
gosub chatting
endif
rem Draw HUD
gosub hud
rem Display the messages and the effects of the granades
DisplayMessages()
UpdateGranades()
prevHP = health
rem Update physics
phy update
rem Send multiplayer data
if TConnected() = 1 then gosub network
if msge <> "" then msge = ""
TSync
return
Recive data function:
function RNetwork()
rem Get the sender
sender = TGetSender()
posX# = TGetFloat()
posY# = TGetFloat()
posZ# = TGetFloat()
ax# = TGetFloat()
ay# = TGetFloat()
msge$ = TGetString()
enna$ = TGetString()
if msge$ <> " " and msge$ <> " " and msge$ <> " " then AddMessage(enna$, msge$)
rem Position the sender
position object sender, posX#, posY#, posZ#
rotate object sender, ax#, ay#, 0
rem Get the new positions of the objects
for n = 0 to array count( objectsI() )
if objectsI( n ) > 0
rem Get the position of the object
ox# = TGetFloat()
oy# = TGetFloat()
oz# = TGetFloat()
rem Get the angle of it as well
oax# = TGetFloat()
oay# = TGetFloat()
oaz# = TGetFloat()
rem And get the speed of it to
lvx = TGetInt()
lvy = TGetInt()
lvz = TGetInt()
rem Apply the position, angle and speed of the object
phy set rigid body position objectsI( n ), ox#, oy#, oz#
phy set rigid body rotation objectsI( n ), oax#, oay#, oaz#
phy set rigid body linear velocity objectsI( n ), lvx, lvy, lvz
endif
next n
endfunction
Send data subrutine:
network:
rem Send the data of the player
TPutFloat object position x( player )
TPutFloat object position y( player )
TPutFloat object position z( player )
TPutFloat object angle x( player )
TPutFloat object angle y( player )
TPutString msge + " "
TPutString plna
rem Send the data of the objects
for n = 0 to array count( objectsI() )
if objectsI( n ) > 0
rem Send the position of the object
TPutFloat object position x(objectsI( n ))
TPutFloat object position y(objectsI( n ))
TPutFloat object position z(objectsI( n ))
rem Send the angle of it
TPutFloat object angle x(objectsI( n ))
TPutFloat object angle y(objectsI( n ))
TPutFloat object angle z(objectsI( n ))
rem Send the speed of the object to
TPutInt phy get rigid body linear velocity x( objectsI( n ) )
TPutInt phy get rigid body linear velocity y( objectsI( n ) )
TPutInt phy get rigid body linear velocity z( objectsI( n ) )
endif
next n
rem Send all data
TSendAll
TSync
return
I just noticed there where two 'TSync' commands. Note that I once only had one, but it didn't work any better then.
And one more thing. The entire source covers 1966 lines at the moment, which is my reason for not posting it.
Please help me. I really need this to work.
Thanks for your help.