Something is wrong with ROBLOX’s physics

ROBLOX isn’t working. 

James Onnen (Quenty)
Roblox Development

--

This is basically documentation of what is wrong with my ships.

On ROBLOX, I’m making a ship with simulated sails. It works great in solo test mode.

But as soon as I stick this guy online, there are a host of problems. First of all, you should know how it works.

Basically, it turns a group of parts into “sails” into a mesh based out of vertices. These are then connected/linked, and then the positions / physics are simulated using verlet integration.

It looks rather pretty. On online mode it jumped all over the place.

So here’s what I have done to try to fix it. I started out by trying to optimize it. Some optimization later, I realized “Wow, ROBLOX does not like replicating welds well.” This reduced a ton of lag out of my game. I moved the whole rig to be local on the characters side, stuck it into a local camera, and then simulated the physics locally.

I then realized the pin locations were messing up, and that the sails were jumping around because my physics model was messed up in calculating some of the values. I updated the physics model to not be relative to the ship, but be relative to the whole world.

I realized this would not work out too well for each ship, so I created a task manager that would yield and un-yield the ships, optimizing it so it only rendered the ships when they were close.

The way the physics worked, was that it welded the sails to the ship. Simple enough. Nope. Not with local physics. ROBLOX’s physics themselves are simulated on the server and on the client. The clients share loads and send results back and around.

Turns out that those little parts on the sails that were local were actually sending wrong results. I moved, rather reluctantly, on Anaminus’s suggestion, to an anchor and render stepped system.

No more physics glitches from ROBLOX.

Unfortunately, this meant I had to run the render at every single render frame. That’s fine, I set it up, and it worked out ok. The sails updated, and all that. Except, as you may have expected, on online mode.

The sails, as you might expect, jumped horribly online. They also were “tearing.” I figured maybe the sails were updating across render steps, the process I using, perhaps, to inefficient.

I optimized all my code. Again. And again. I did memory management, moved the verlet integrator solver to a more presuming-more-efficient system. I updated the rendering system. I rewrote the triangle calculator three times, making it 300% faster. I removed sixty parts from the ship by generating the model on the server and sending it through the client, discovering a few ROBLOX glitches in the process of doing it.

I went from a 20-30 FPS rate to 60 FPS consistently. It still did not work.

After looking at my ship, I finally realized that the character, and the sails, were actually synced when the camera was attached to the ship. That is, they both jumped horribly around, but their relative displacement was consistent.

You can see how ROBLOX groups physics by who is responsible for it. Right now, the server is responsible for the ship.

I am now convinced that ROBLOX’s render and CFrame and not actually synced, or at least, something is wrong. For example, whenever the ship jumps to the control of the client, from the server, in server test mode, the ship gets teleported back to the location it was last at for the client, before jumping back. Sometimes the client notices.

Depending upon the ownership of the ship, the sails jump more or less. When the server controls it, they jump like mexican jumping beans.

When the client controls it, they are perfectly synced (and so are the characters).

The client is controlling the ship, and the sails are synced. You can see this is achieved by making sure there is contact between the client and the ship.

In looking at the networking, the same problem occurs without the network latency or lag. That means it is something ROBLOX is doing, because the characters and sails jump at the same rate, at the same time. It must be how ROBLOX is handling parts, and networking, or something….

Under mixed control (I’m fairly sure that’s what “red” means), the sails jump in a little quantity.

So my question to ROBLOX’s network engineers is if the CFrame I’m reading is the same as the CFrame being rendered. Is there a way to get ROBLOX to always local-control a ship?

I’m fairly confident that if this issue is fixed, so too would the character-flickering-on-vehicles issue be fixed.

I just wish it wasn’t this complicated. It’s why I make things on ROBLOX.

Update

You can see the character shifting around here. This is with interpolation off.

Alright, this is an update, after a few weeks after this post. I’ve got my character bouncing around here, with interpolation off. This is all fine and dandy, the sails are actually not desynced from the masts anymore. However, they are still bouncing like crazy.

I’m pretty sure that I’ve identified two problems. The first is something to do with the way I’m reading velocity or something, perhaps a problem with my own code where the ropes pull upon each other. I suspect it’s the velocity though, because the sails bounce with the character.

Ah yes, the bouncing character and sails together, along with the lovely splitting sail!

In the picture about, you can see the booms (the thing that rotate around the mast), are stable, perfectly synced with the camera. This is because I have interpolation off. Here’s what it looks like with interpolation on.

Ah yes, the bouncing sails, along with the bouncing character, and more bouncing sails! This is with interpolation on.

So why would sails bounce with the character? What’s related? Well, I’m using velocity to calculate the wind in the sails, sort of a reverse physics thing to allow players to control the boat. When the sails get larger and then smaller quickly, so do the characters bounce around more relative to the ship.

That is to say, both are probably predicting position based upon an inaccurate velocity. I can probably fix this, that’s probably possible

No, the other issue I’m facing is one in the rendering department. The problem is in resizing the sails (the wedges/triangles) to math the position they’re suppose to be, sometimes they tend to uh, lag a bit, in resizing. This is either because my algorithm is slow, which I think I’ve eleminated, or perhaps it’s because ROBLOX doesn’t render it fast enough.

How so I know it’s ROBLOX not rendering it not fast enough, and not my algorithm? Because I can drag my ship around in ROBLOX studio and the sails glitch the heck out until I stop moving it. A few milliseconds later, and it’s rendering again perfectly. Without any bit of my algorithm changing.

Yes, there is definitely a lag in wedge meshes updating. And not just that, but parts too (although these create serious lag).

So all in all, the issues I have are something along the lines of.

  • No way to get the interpolated CFrame, so the whole model bounces if interpolation is enabled.
  • No velocity reading, sort of my fault, perhaps, but it also breaks ROBLOX’s characters, which is annoying if you aren't sailing the ship
  • No accurate way to actually guarantee the sail renders.

Meh. Networking. (By the way, this is what the networking physics ownership looks like when I’m the only one driving)

Should be purple, like my character. ROBLOX doesn’t like purple, I guess.

--

--

James Onnen (Quenty)
Roblox Development

I’m a maker. Designing and creating new things with people is my hobby. Former intern @Microsoft, @Roblox, @Garmin. Roblox Toy. Raikes 2019.