Author Topic: Interpolate Movement  (Read 4793 times)

Voxel

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 35
    • View Profile
Interpolate Movement
« on: June 24, 2013, 04:09:23 PM »
Hi Aren,

I have both server and locally hosted setups working with my test FPS game, simply brilliant! One problem I am facing at the moment is that movement is very jittery at times. A friend of mine connected with a ping of around 150 to 200. The jitter is almost non existent on LAN. So....

I am wondering if it is possible to smooth movement using network interpolation inside of TNet? For example could these scripts be converted for use with TNet or would I be wasting my time?
http://wiki.unity3d.com/index.php?title=NetworkView_Position_Sync

Or do you have a better suggestion seeing as everything else you have suggested in other posts has been spot on.

Thanks.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Interpolate Movement
« Reply #1 on: June 24, 2013, 05:20:42 PM »
Yep, you can do it. What I generally do though is separate the renderer from the rigidbody. You can see it used in the 2nd example as well. This way even if physics jitter, the renderer seems to follow smoothly. I'm going to release a new kit shortly that also takes advantage of this approach.

Voxel

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 35
    • View Profile
Re: Interpolate Movement
« Reply #2 on: June 24, 2013, 05:36:57 PM »
Hi ArenMook,

"I'm going to release a new kit shortly that also takes advantage of this approach."

Are you referring to interpolation method similar to the wiki script? Also I already have the renderer separate from the rigidbody which you mentioned in a another post. It's perfect on LAN but internet play still needs the interpolation.

Are we talking months before the release of the kit? I know timescales are a nightmare and I will not hold you too it lol! ;)

« Last Edit: June 27, 2013, 05:38:26 PM by Voxel »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Interpolate Movement
« Reply #3 on: June 29, 2013, 04:11:45 PM »
I already released it: http://www.tasharen.com/forum/index.php?topic=4780.0

And yes, it just uses the separated renderer method. I set the transform auto-sync to only update 4 times per second, but generally that number can be dropped to even only once per second if needed. It all depends on the latency, and how much bandwidth you're using. With a slow network connection updating too frequently can be worse than updating infrequently. The separated renderer method can be quite effective but may need to be approached differently (ie: I sync what causes the rigidbody to move frequently, and the actual pos/rot is sync'd infrequently).

Voxel

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 35
    • View Profile
Re: Interpolate Movement
« Reply #4 on: June 30, 2013, 10:11:47 AM »
Bought and now in use! Huge improvement on before, both in terms of almost no jitter across the internet and also sending 75% less packets than before. Thanks as always!

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Interpolate Movement
« Reply #5 on: June 30, 2013, 09:48:35 PM »
:)

ankharlyn

  • Guest
Re: Interpolate Movement
« Reply #6 on: July 01, 2013, 12:53:57 PM »
@Aren, I understand this approach applied to the examples. What I'm curious about is how it would work with an animated player? Does the spring component script go on the armature instead of the renderer in that case?

Edit: Looking at the Unity script reference, it seems like what I see as named "Armature" is a SkinnedMeshRenderer. Is that correct? If so, I imagine I can use it just like a MeshRenderer in TNet's second example.

Please let me know if I'm on the right track.
« Last Edit: July 01, 2013, 04:03:19 PM by ankharlyn »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Interpolate Movement
« Reply #7 on: July 01, 2013, 08:57:31 PM »
SkinnedMeshRenderer is still a Renderer, so yup.