# Interpo-what? Smoothing the Motion of Networked Objects

Dictionary.com defines “interpolate,” in mathematical terms, as inserting, estimating, or finding an intermediate term in a sequence. As dry as it sounds, it’s the reason objects are moving more smoothly in ROBLOX. Software Engineer Yunpeng Zhu is here today to explain how he improved ROBLOX’s physics interpolation, and to share some telling video evidence.

Anytime you take a video game online, there will be latency. The trick, for ROBLOX and other game developers, is to find efficient ways to manage the latency and keep players from perceiving it as lag – a freeze or slowdown in gameplay caused by a break in the flow of information between server and player.

## Prioritizing physics objects

The latency challenge is unique for ROBLOX because each user-generated game can have thousands of physically simulated parts. The game server must constantly send data for these parts, such as position and velocity, so players see can what’s happening, as it’s happening. Depending on the number of moving parts and available bandwidth, it can become impossible to send position data for every moving object 30 times per second.

To get around this problem, ROBLOX game servers send more data, at a higher frequency, for moving objects that are close to the player. This video shows the level of priority reflected on in-game objects. As the player moves, so too does the high-priority red zone.

## Interpolating physically simulated moving objects

With the server sending out data in the most efficient way, we can work on hiding latency and “choppiness” on the player side. We can’t remove the latency – that’s not possible when a network is involved. But we can mask the choppiness with interpolation. Choppiness results when there is not enough network bandwidth available to update the position of an object at 30Hz.

The above graphic shows a ball’s position, as seen by the player, without interpolation. Notice the distance between each step. This is the result of network updates occurring more slowly than the rendering frequency. If we were to successively render the ball in ROBLOX at these exact locations, it would appear to jump from one position to the next.

The above image shows the same data, but with interpolated steps, as indicated by the grey circles. If we render these interpolated steps, along with data received from the server, the ball will appear to move smoothly from one position to the next.

## Putting it together

ROBLOX servers send more data, at a higher frequency, for physics objects that are close to the player. Interpolation then fills the data gaps, smoothing out the motion – even of far-away objects. This video shows the new interpolation code in action.

##### Left: Old interpolation code. Right: New interpolation code.

Longer data history: We keep a more comprehensive history of data received from the server. Previously, we kept only the last two data points from the server, which caused stuttering when data was cycling in and out quickly. Now, we can fill the gaps between every pair of interpolation points before moving on to the next.

Flexible data history: The game server sends data more often for objects that are closer to the player, so we can track the frequency of updates and use that information to determine how long of a data history we should keep for a given object. This ensures we’re interpolating using the optimal pairs of data.

Extrapolation: It’s not unusual for data from the server to arrive late or get lost. We use extrapolation in such situations to predict future position based on historical data – think of it like calculating, based on the previous few positions, where a part might end up. It’s very difficult to accurately predict movements of player-controlled characters, so we only extrapolate up to about 1/5th of a second.

We are continuing to tune and improve our physics interpolation. It won’t change how you interact with ROBLOX, but it will improve your user experience.

## 295 thoughts on “Interpo-what? Smoothing the Motion of Networked Objects”

1. ok the ball thing and the other thing are good real good for people with old computers (which is me :P)and its not jerking also so it will greatly improve perfromance good job guys :D

2. On the old roblox I used to get puzzled, because when I exploded blocks, they randomly stopped and started in the air, kinda like hovering really. Anyway, thanks to the roblox upgrade, that won’t happen!

3. I personaly think you are right. lol this is my first time bloging. this article is awesome and cool RABIDBIG out.

4. Ah, the revamped interpolation code seems nice, although you guys should keep working on it a little more. When I looked at the video, it skipped a few frames of the bouncing animation.

5. I think that this idea of interpolation will help with smoothing out movements, but users oftentimes do not have a supercomputer at their disposal. The physics engines are exceptionally good, better than any other I’ve seen, but I think it would be better if the framerate was reduced to 20-30 FPS. Having slower framerates but better anti-lag is better for most than having a higher framerate and a lot of lag. I understand the amount of data is massive, but he slower framerate could allow for this information to be sent a little more slowly, until technology catches up with the information quantity. I have an older computer (Dell 2006 Windows XP) and it routinely is at full CPU capacity while playing games with very little motion. On larger games, it can overheat, so maybe a lower amount of information is better for the moment, until computer technology catches up with your codes.

• My computer will probally still have troubles, and it’s fairly new(HP 2009 Windows 7). It fluxuates between 1%-25% CPU capacity just being idle.

• My new computer is super fast and it shouldn’t have any problems with Roblox because it has a graphics card. When you know how to build computers, you can get extremely good ones for low prices.

6. Finally, they are working on a way to get rid of lag more! I am so glad they are finally trying because I went to Egg Hunt 2012, and let me tell you, it lagged so badly, I had to enter the game 20 times just for the “Waiting for Character” text to pop up! But I got all the eggs, even though the game lagged the whole time I was there.

7. For all the people saying lag increased, it might be because they save part positions for longer and possibly do more math on it, so you need a bit more RAM or something.

• It is most certainly no where near as laggy as an older version of roblox. The older version of roblox was really choppy even on my gaming computer. This version of roblox runs extremely smoothly. I don’t get frusterated like I used to anymore

8. This is great! I remember when all that lag from games would slow down the fall of bricks. However, if this helps the fall of bricks %90 of the time will it not slow down blowing up a building on ROBLOX like Roblox World HQ that place lags like crazy when you blow one or two towers up.

-Pieperson50

• I would like you to read what you just said then explain to me what the heck it means :)

9. Well yes, I love a new pysics engine, itis causing much lag. I can no longer build or play at all. Please fix this. I am using a high powered computer, and it’s slow.

10. It will probley make more lag because the new one looks like it goes faster and might increase frame rate

11. Just a question..

Since interpolation is estimating or finding an intermediate term in a sequence, this got me thinking; You were able to interpolate the position of physics-based objects, and I was wondering if you can update so that this is also possible to interpolate two Camera CFrames, and two Camera Focus Vector3′s in an easier manner. This’ll help many cutscene-makers out there, instead of having to do the math and write lots of loops, taking up more lines of code.

12. I find this Okay. I was hoping for many more features throughout my 5 years of playing. I means, physics look better, but does that mean we will still have the better servers? Or the wonders of dynamic light and dynamical destruction many F2P games now offer today? I believe roblox will be much more of a attractive game if it these main features are added. I mean G-mod 12 is going to rule the sandbox gene now

13. I read the first paragraph then thought it was boring. I guess it’s saying that they are reducing lag. Doesn’t really bother me because I rarely have lag even though I have the slowest computer ever.

• They aren’t exactly reducing it, they’re just making te game run faster, closer to where you are. So it’s like moving the lag to a further away place, until you get close to it.

14. Nice Good work on it Now players can have more Better moving Physics around :D

15. Finally better physics I have wanted that for a long time can you make a scene maker and an animation thing instead of having to script it?

• Yeh, I’m a rubbish scripter every attempt that I make is just a pile of poo, no matter how hard I try it does’nt get me anywhere (I’ve read the wiki and all! >:O) I’ve asked countless members of my family but they just can’t seem to help!

16. Epic. And just a quick question, How did you make the spheres endure such a long time bouncing? Nice job.

17. Now, this is a real update with effort… I cant believe im saying this but keep the good work making something like the above..etc…

18. Could the physics be configurable? this can fix some games that were ruined with the previous update and enhance the ability to make new and better games.

KTHXBAI

19. Cool! Looks like you guys have definitely improved with the physics since you started 05-06… Hopefully next on the list: No trip glitches/random flying around

20. its nice to see where our bc money goes ;D keep up the great work roblox staff

21. But say it was a rocket brick… Would it effect the way I don’t get touch, but still explodes at me…as the timing is ever so smoother but still holds different lag timings…

22. this is great, the video clearly shows much smoother motion. Glad to see that ROBLOX is actually working on such issues.

23. its pretty easy to understand. I’m lookign forward for the new physics update,but im looking more forward to the dynamic lighting,bouyancy etc from the hack weekend.

24. This is actually very good. I’m not sure if you’ve always done innovation such as this, or if it’s the first time that you’ve actually talked about it in place of talking about your endless hats.

Whatever the change was, however, continue doing it. THIS is how you run a proper game.

25. well its hard to explain so i’m going to use 2 words to describe this.
Stop Animation
your basicly adding more frames like stop animation.Great job, but what i really want to see is terrain generator water, buoancy, bridges,
and dynamic lights, the ones used in hack week

• ever play xlegoxs train game i was thinking it work sortta like that for rope bridges

26. ya, it doesn’t get rid of lag lol. it just made the engine a lot better and will make it so you can see objects moving around correctly. i personally don’t have any lag anyways…

27. Note:
This shall not “Remove” lag it just upgrading the physics engine.
Wich is like “Layers” on video games.

28. It would be interesting to see how this improvement stacks up against demanding games…such as takeovertom’s vehicles with suspension.

29. So, basically: Geek word, geek word, geek word, “Lag Reduced” geek word, geek word, geek word. No offence to people who understood the above article. It just means your smart! :)

30. If my understanding is correct, we’re going to nuke the lag. Game hint given, John knows what to do next.

31. As mentioned in the article, this DOES NOT reduce lag, but rather there is better priority and interpolation of the closer objects, so it will SEEM LIKE the objects are “less laggier”.

32. What you should do is make it so that the User can set [or have it set automatically] on stuff like how often it re-sends the info. That way, faster computers can have even better experience.

33. This is a great idea! It’ll be sure to decrease lag! Also, the old view of the moving particles could of also been effected by lag, which doesnt let the particle flow smoothly, decreasing lag too, would make it flow more smoothly. I hope you like my idea!