ROBLOX is built on a comprehensive physics engine, and our developers are constantly optimizing it so it can handle interactions between more physics objects and players, in an increasingly accurate and consistent way. We recently put our engine to the test with a new projectile-motion simulator – and most satisfying armament – the ROBLOX Potato Cannon. According to the results, which we describe in this article, we’re on the right trajectory.
The ROBLOX Potato Cannon mimics its real-world counterpart, a contraption traditionally constructed using a pipe and some means of generating air pressure. The difference is our potato cannon automatically performs the calculations you need to hit your target. We constructed the potato cannon so it computes the launch angle and, with the velocity at a constant 300 studs/second, the correct trajectory for your now-deadly potato. If your target is outside its range, it defaults to the maximum distance it can shoot.
Let’s look at how we calculate a potato’s trajectory for maximum distance and how the ROBLOX Potato Cannon stacks up against real-world physics.
Potato Cannons: ROBLOX Vs. Real World
In ROBLOX, one real-world meter is 20 studs. We can use that conversion to determine ROBLOX’s acceleration due to gravity. In the real world, acceleration due to gravity is 9.81 meters / second^2. When we multiply that number by 20 studs, we arrive at the acceleration due to gravity in ROBLOX: 196.2 studs / second^2.
With the muzzle velocity of our Potato Cannon at 300 studs/second, we can determine the Maximum Distance, Maximum Height and Time Traveled (twice the time it takes to reach the maximum height, assuming there is no air resistance) for the projectile.
θ (Theta) is the launch angle of the projectile. The projectile will reach peak distance when θ = 45° – see the Wikipedia article on projectile motion for more information.
When we plug in our values for velocity (300 studs/second), launch angle (45°) and acceleration due to gravity (196.2 studs / second^2), we can compute the Maximum Distance, Maximum Height and Time Traveled as:
We can compare these calculations to the in-game performance of the ROBLOX Potato Cannon. Our results show that its trajectory is almost exactly what we calculated in the above formulas.
You can see that the distance, height and time traveled, as simulated by ROBLOX’s physics engine, are very close to the real-world values. We suspect the marginal error in Maximum Distance is probably due to the “touch” events not polling fast enough and the discrepancy in Maximum Height is due to the Lua-side polling performed by the script.
Sure, the ROBLOX Potato Cannon is an intimidating piece of virtual gear you can tote around with your character. But it’s also a physics lesson in disguise — one that verifies the accuracy of ROBLOX’s engine.