Author Topic: Tnet Syncing Movement (Jumping Issue)  (Read 2217 times)

WolfTechGames

  • Newbie
  • *
  • Thank You
  • -Given: 6
  • -Receive: 4
  • Posts: 35
    • View Profile
Tnet Syncing Movement (Jumping Issue)
« on: November 13, 2015, 08:39:33 PM »
It syncs movement smoothly but the jumping turns out to be jittery and looks bad in the end.

  1. void Update()
  2. {
  3.      if(tno.ismine)
  4.      {
  5.            //Sync Data
  6.            tno.SendQuickly(1, Target.Others, transform.position, transform.rotation);
  7.       }
  8.       else
  9.       {
  10.              //Interpolate
  11.             transform.position = Vector3.Lerp(transform.position, realPosition, Time.deltaTime * 5f);
  12.             transform.rotation = Quaternion.Lerp(transform.rotation, realRotation, Time.deltaTime * 5f);
  13.        }
  14. }
  15.  
  16. //Interpolate
  17. [RFC(1)]
  18. public void syncData(Vector3 newPosition, Quaternion newRotation)
  19. {
  20.      realPosition = newPosition;
  21.      realRotation = newRotation;
  22. }
  23.  
  24. //Do Jump
  25. if(Input.GetKeyDown(KeyCode.Space) && canJump)
  26. {
  27.        //Add Force
  28.        GetComponent<Rigidbody>().AddForce(Vector3.up * playerJumpForce);
  29. }
  30.  

phoenix

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 3
  • Posts: 49
    • View Profile
Re: Tnet Syncing Movement (Jumping Issue)
« Reply #1 on: November 16, 2015, 11:23:33 PM »
I am guessing that Aren's answer will be similar to others who have similar issues, dont sync the players movements, sync the input triggering the movements.

He talks about this in his FAQ

and also here http://www.tasharen.com/forum/index.php?topic=13615.0

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Tnet Syncing Movement (Jumping Issue)
« Reply #2 on: November 18, 2015, 04:21:11 PM »
Yes, precisely.

Also NEVER EVER EVER send anything in every Update(). It's not only horrible practice as it's tied to the framerate, but you will flood the network doing so. Think about it... someone who has 10 FPS will send 10 updates per second. Someone who has 1000 FPS will send 1000 updates per second. You will flood the network in no time, which means that packets will be sent in batches instead -- causing the updates to be jittery (think receiving 50 packets at a time instead of 1 at a time).