Working with model physics on ROBLOX

Getting that vehicle to move just right…

James Onnen (Quenty)
Roblox Development

--

So it turns out ROBLOX’s physics are very approximate, and rather hard to work with.

You may be surprised if you have not been on ROBLOX for long. Most of us are not. The truth is ROBLOX is a game, and we can’t expect perfect physics. However, you do have to keep a few things in mind when working with vehicles.

First of all, most people use a few “BodyMover” objects to work with vehicles, these include things such as “BodyGyro” and “BodyVelocity.”

If you want realistic vehicles, avoid these like a plague. You see, real vehicles work, well, without magical forces upon them. So when you make a car, just use wheels and a motor. When you make a boat, just set velocity directly. You may gripe and complain, but it makes a lot more interesting effects, and a much more fun vehicle to drive.

So what about setting velocity, you say?

Well, I have noticed a few things kind of wrong when it comes to velocity and forces. First of all ROBLOX groups parts that are connected via joints together into one physics model. Yes, that is right. ROBLOX treats connected parts as one physics body. This makes sense, the velocity of one connected part should be the same as another.

This, however, is bad for us, trying to set velocity. well, it’s good and bad. It means that it does not matter what part gains a velocity, the whole model gains and moves at the same velocity, relative to the center of mass.

This is also the bad thing. Because when things get added to a model, the whole model gains a new velocity, this time, defined by the thing just connected to the model.

A nice side effect of this is that your model is actually more efficient as a single group than probably 1/3 of the pieces, but all separate.

When you start welding players to a ship or a vehicle, things start looking a bit funky. Now, humanoid models also manage to stop literally any force coming at them, they basically deny physics, but when you weld them to a ship while they’re seated, they’ll generally respect the ship or vehicle. Otherwise, your ship may start marching along in a whole new direction.

If this was real life, walking on a treadmill could be extremely threatening.

The humanoid issue is just a byproduct. The main issue is when it comes to applying forces to a ship or vehicle. There is nothing more amusing than seeing your car fly into the sky after a long day.

When I started trying to make my ships more realistic, at one point, I tried to calculate sails dynamically, with the help of Trey. Trey had a great algorithm. The problem with it was that after calculating the force to apply, I applied it by adding to the velocity. That had the unfortunate unrealistic effect of speeding my boat off in a rather fast fashion. It also removed any possibility of awesome tip effects from the sails being blown upon.

Cannons were my next objective. After failing to get the sails to work, I wanted some recoil built into my cannons. Newtons laws told me equal and opposite, so given there was a 500 meters per a second cannon ball flying out one end, I thought It would be fun to apply a 500 meters per a second velocity in the opposite direction.

I’m telling you now, neverland is real. I saw that flying ship!

Right now, I am trying another thing. It is called math, and with the help of Trey, perhaps I can get this to work.

We are calculating the center of mass for the ship, and then applying a velocity and force based upon another opposite force and position that is offset from the center of mass.

For Trey this is fun.” For me, not quite as excited by math, this is more of a horror story, one marked with hours of debugging and figuring out what the heck is going on.

Dear ROBLOX engineers reading this,

Can we please get a BasePart.ApplyForce(Vector force)? Would this not make everyone’s lives easier?

Sincerely, Everyone trying to do physics

--

--

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.