Falling, with Style
You’ll want to Jump into this Game Mode!
Hi, I’m Dave Avram. I’ve been working at Sony online for the last 9 years, developing tools to make certain games run smoothly by the time they get to you. On the H1Z1 team, I’m responsible for implementing all sorts of different things, running the gamut from the tool the designers use to place objects in the world to writing code to make the guns fire, to making sure the wheels don’t fall off of the vehicles while you are driving them.
I was recently asked to assist in the development of a feature for one of our upcoming game modes. In this Game Mode, the player starts the round by falling out of a plane, then parachuting down to the ground, and are able to steer the parachute to an extent and pitch up and down to control their speed.
Unfortunately, the only vehicle or control model similar to this in our code base was the drop pod from PlanetSide 2 - we had to make something for the most part that was brand new functionality based on something that had some similarities to what we wanted.
In order to develop this, I needed to attach the player to a vehicle. Since an artist is still working on the model for the parachute while I’m developing the code for this, I will be using the good old Off Roader and changing the data behind the scenes. This is done because we want to allow the parachute to behave as a vehicle, be controllable, and follow the dynamic effects as a vehicle would, and allow a player to attach to a socket on the model easily.
The first thing I looked at was how we wanted the parachute to fall; the drop pod in this respect simply accelerated to its max speed as soon as it spawned and used what we call a dampener to prevent itself from falling faster. The dampener works by pushing or pulling the object in a direction along a local axis – in this case, the Y or vertical axis. This caused the object when pitched forward to move forward, and pitched back to move back, as well as stopping vertical acceleration.
The green lines represent the Y axis, or the vertical. The tri-color axis in the lower right is the world axis, and the one on the off-roader represents the relative rotation of the object to the world, or local axis. In general, we don’t want this to happen with our parachute. The parachute needed to work by slowing down only along the global vertical axis, and maintain its speed along the X and Z axis. To produce something similar to this, I tried a simple rule - if I’m falling faster than I wish to (10 meters/sec or so), I apply a small linear force in the opposite direction – mainly up. This causes a nice smooth change in acceleration as the parachute approaches its terminal velocity, and holds it at that speed as it falls.
The next item that comes up is the matter of control. The drop pod allows for some manner of control, allowing you to move side to side or front to back, similar to firing a thruster in a direction opposite the way you wished to travel. We want something more akin to a glider, where there are no maneuvering thrusters. The only propulsion you can achieve is by altering the shape of your parachute, and trading drag for angular (turning) velocity. This type of control feels more akin to using an airplane joystick, where moving the mouse left/right banks the vehicle to the direction you point to. Pushing forward pitches the parachute towards the ground, and pulling the mouse back pitches the parachute up. The pitch controls are invertible in the settings.
Since there is no forward thruster, and we are allowing gravity to add to our horizontal speed, but counteract that with a straight up vertical thrust to simulate the parachute’s drag, a neat thing happens – we manage to allow the physics simulation to let us build linear momentum based on our pitch, and preserve that inertia in a direction as we fall. Since the local velocity along our forward axis (X) is preserved, if we pitch back up a little from vertical, we can then accelerate in a direction as we fall – and use that momentum travel parallel to the ground.
There is one consequence of the current simulation that arises, in that there is now no consequence for pointing the chute straight down and gaining as much speed as you can, since your vertical speed won’t increase. To resolve that problem I changed our earlier rule to allow our designers to set a maximum terminal velocity as well, and then set the maximum fall velocity for any particular moment to be:
V = (Max Terminal Velocity – Min Terminal Velocity) * (current pitch / 90)
This ends up allowing the force pushing up (vertical drag) to be proportional to the angle of pitch (0 being parallel to the ground, -90 being pitched straight up, 90 being pitched straight down. This is simulated by allowing a higher velocity for a higher pitch, and a lower velocity for a lower pitch. It also means that if you pitch up to much at a low speed, you start falling backwards!
Thanks for reading this long winded article, and I hope to see all falling from the skies online soon.