Skip to main content

Blog Archive

Robust Joints and Motors: Keys to Better Vehicles in ROBLOX


27, 2012

by Kevin He


Advanced Physics - Robust MotorsAt ROBLOX Game Conference 2012, Kevin He dissected the steps he’s taken to refine ROBLOX’s water physics, hinges and motors so that vehicles – especially boats – perform more realistically. In this blog post, we’re recapping the key parts of the development process. You might be surprised at how much work goes into physically simulating real-world machines in a life-like fashion.

ROBLOX’s water, released in June, gives you the ability to create a boat that floats based on actual physical properties, rather than lines of Lua code. While the release of water marked a big step forward for ROBLOX, it has its limits; for example, if you want to create a propeller-powered boat, the propellers have to be on the side of the boat, as though they’re mimicking wheels on a car.

We’re working toward releasing a vehicle seat that gives players greater boat control, namely over rear-facing propellers that function based on real physical forces. It sounds simple, but it’s actually the culmination of two complex physics engine developments.

Water Physics and Buoyancy1. Advanced water physics

ROBLOX’s water accurately simulates buoyancy, so objects float (or not) and orient themselves based on the density of their material makeup. But the current water simulation doesn’t take into account the angle at which objects move through water and the resulting amount of water viscosity (or resistance).

The next water release will. As you can see in the videos below, objects will slide through the water on a trajectory that matches their angle, and at a speed that correlates with their size and shape. For example, a flat, angled part shoots through the water, while a wide object situated perpendicular to the surface will sink slowly. Compared to our original model, it’s more intuitive.

Parts move through water more accurately under our advanced water physics.

This is one key to working boat propellers. The fins of a boat propeller move through the water at an angle, not perpendicular to the surface.  Our advanced water physics simulate the force generated by the angled propeller fins spinning through the water, thereby pushing the boat forward.

2. Robust, stable hinges and motors

The force of a propeller is only as good as the propeller’s ability to stay rigid and strong under water. Rigidity and strength required that we make ROBLOX’s hinges and motors more robust.

The hinge, for a boat motor, is the axis around which the propeller fins spin. If the hinge is not rigid – or has a “weak constraint” – the fins will wobble and the force the propeller generates will go in multiple directions, which is not efficient for generating speed and maintaining a steady direction. If the motor is not strong – the result of insufficient joint stiffness – it will not be able to generate enough torque to rotate in water.

You can see our progress in the following video. Notice that the new joints are rigid (less wobbling and bouncing) and the new motors are strong (parts rotate rhythmically and with little wobbling).

More rigid joints wobble less and make for better motors.

Our goal is to make all joints in ROBLOX as rigid as they can be. However, we can’t make the physics engine arbitrarily stiff because it may over-correct simulation errors and eventually destroy mechanisms. Instead, we are introducing new optimizations to reformulate the joint constraints and make them more accurate. We’re also implementing a new formula to automatically pick the optimal stiffness constant for a given mechanism and a dynamic “physics-simulation step size” to add simulation detail to parts of the world that are particularly challenging to stabilize.

This video demonstrates robust hinges and motors on a battleship, speed boat and monster truck.

A vehicle seat for boats

ROBLOX players take control of cars by sitting in the “vehicle seat,” a special part that gives them control over the vehicle’s wheels. Currently, game creators are inserting vehicle seats on boats, which allows players to control side-mounted propellers. It works, but it doesn’t allow creators to build realistic boats.

We are developing the next generation of vehicle seat that, when installed on a boat, automatically detects back-mounted propellers and lets users control them using the keyboard.  The new vehicle seat will be implemented in Lua, exposing to scripters the underlying logic that wires the wheels and propellers together. Not only will it support boats, but also be more customizable than the current vehicle seat.

Demonstration of the vehicle seat controlling two rear-facing propellers (and their power).

This next-generation vehicle seat wouldn’t work without robust hinges and motors. And they wouldn’t work without advanced water physics. So, while the new vehicle seat is relatively simple, we had to focus a lot of effort on further developing our physics engine to give it purpose.

We’re also working on additional joint types, which we will cover in the future:

  • Revolute joint/motor
  • Rope joint
  • Rod joint
  • Spring joint
  • Ball/socket joint

As abstract as those joints may seem today, they’ll open up a world of possibilities for ROBLOX game developers in the future. Stay tuned for more.