I have a game I am working on....the animation works great for the main character (local) but when the game is updating network players...how do I make the walking animations work as a network player is updated?
chris
posted below is my code for network updates
Function UpdateNetwork()
While RecvNBMsg(mainstream)
Select NBMsgType(mainstream)
Case 100 ;New Player
serverid$ = converttoid(serverip,serverport)
If nbuserid = serverid
checknbdatabase(mainstream) ;Make sure the host only does this
ElseIf nbuserid <> serverid ;If you are not the server
i.nbplayer = New nbplayer
i\name = nbmsgdata(mainstream)
i\ip = nbmsgip(mainstream)
i\port = nbmsgport(mainstream)
i\id = converttoid(i\ip,i\port)
EndIf
p.player = CreatePlayer(0,10,0, nbmsgfrom(mainstream) )
pack$ = EntityX(play\entity) +" "+ EntityY(play\entity) +" "+ EntityZ(play\entity)
SendNBMsg(1,pack,nbmsgfrom(mainstream),mainstream)
pitch# = EntityPitch(play\entity)
roll# = EntityRoll(play\entity)
pack$=LSet$( pitch,7 )+LSet$( EntityYaw(play\entity),7 )+LSet$( roll,7 )
SendNBMsg(3,pack,nbmsgfrom(mainstream),mainstream)
Case 101 ;Player Left
For p.player = Each player
DebugLog("entity id:"+p\net_id +" netid:" + nbmsgfrom(mainstream))
If p\net_id = nbmsgfrom(mainstream);Left$(nbmsgfrom(mainstream),Len(nbmsgfrom(mainstream))-3)
FreeEntity p\model
For n.nbplayer = Each nbplayer
If n\id = p\net_id Then Delete n
Next
Delete p : Exit
EndIf
Next
Case 1 ;Position File
For p.player = Each player
If p\net_id = nbmsgfrom(mainstream)
dat$ = nbmsgdata$(mainstream)
Local num1$,num2$,num3$,count
For wc = 1 To Len(dat)
let$ = Mid(dat,wc,1)
If let = " " Then count = count + 1
If let <> " "
If count = 0
num1 = num1 + let
ElseIf count = 1
num2 = num2 + let
ElseIf count = 2
num3 = num3 + let
EndIf
EndIf
Next
p\px = Float(num1) : p\py = Float(num2) : p\pz = Float(num3)
HideEntity p\entity
PositionEntity p\entity,p\px,p\py,p\pz : ShowEntity p\entity
Exit
EndIf
Next
Case 2 ;Movement File
For p.player = Each player
If p\net_id = nbmsgfrom(mainstream)
move = nbmsgdata$(mainstream)
If move = 1 ;Forward
MoveEntity p\entity,0,0,1
DebugLog("moved entity f" + p\net_id)
AnimateMD2 p\model,1,p\anim_speed,3,31,1
AnimateMD2 p\model,1,1,32,100,1
ElseIf move = 2;Back
MoveEntity p\entity,0,0,-1
AnimateMD2 p\model,1,p\anim_speed,1,31,1
AnimateMD2 p\model,1,1,32,100,1
DebugLog("moved entity b" + p\net_id)
ElseIf move = 3;Left
AnimateMD2 p\model,1,p\anim_speed,1,31,1
AnimateMD2 p\model,1,1,32,100,1
TurnEntity p\entity,0,6,0
DebugLog("moved entity l" + p\net_id)
ElseIf move = 4;Right
AnimateMD2 p\model,1,p\anim_speed,1,31,1
AnimateMD2 p\model,1,1,32,100,1
TurnEntity p\entity,0,-6,0
DebugLog("moved entity r" + p\net_id)
EndIf
Exit
EndIf
Next
Case 3 ;Rotation File
For p.player = Each player
If p\net_id = nbmsgfrom(mainstream)
dat$ = nbmsgdata$(mainstream)
rotx# = Float(Mid(dat,1,7)) :roty#=Float(Mid(dat,8,7)) : rotz#=Float(Mid(dat,15,7))
RotateEntity p\entity,rotx,roty,rotz
Exit
EndIf
Next
End Select
Wend
For p.player = Each player
If p\net_id <> nbuserid
TranslateEntity p\entity,0,-.2,0
EndIf
Next
End Function
|