Advertisement
Guest User

Untitled

a guest
Jan 19th, 2019
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.02 KB | None | 0 0
  1. Client
  2.  
  3. PlayerUpdating
  4. In Client PlayerUpdating//called once a frame
  5. RequestStateUpdates();
  6. this will send packet to server
  7. server handles this packet and contains index of sender
  8. server then calls
  9. player[index].SendState()
  10.  
  11. Client handles state
  12. client changes state
  13.  
  14. process current state
  15.  
  16. idle state
  17. i listen for inputs
  18. when input is there i send input packet to server
  19. server handles input changes states to walking and try to move
  20. on server state update (we send this successful update to other clients)
  21.  
  22.  
  23. walk state
  24. I should also be listening to keys so i can keep walking when Iā€™m in walking state
  25. When Iā€™m in walk state
  26. I should Have my position already
  27.  
  28. Send my states animations
  29.  
  30. SendMyRotationToEveryone
  31. send my states SendMyPosToEveryone
  32.  
  33.  
  34.  
  35. Server
  36. How does server send to client constantly?
  37.  
  38. SendState contains
  39. state id
  40. state aim name
  41. state aim play
  42.  
  43. handlinput
  44. player[index].currentstate = walk state
  45. DAtaSender.sendState(to everyone)
  46. player[index].currentState.processInput //calculate movement to send
  47. player[index].currentState.updateMovement() //send position to everyone with angle
  48. player[index].currentState = Idle() //should be a generic (next state) so i can transition to which ever state
  49.  
  50.  
  51. states
  52. idle //by default server is sending idle state to client
  53. processInput()
  54. updatemovement
  55.  
  56. walk // when server receives input it changes the states
  57. processInput()
  58. this will see what keys where pressed
  59. based on this
  60. temp x and temp z will be updated
  61. UpdateMovement(
  62. set player[index].pos = temps
  63. network.sendmovementdatatoall()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement