Tommy is a down-on-his-luck garage mechanic, stuck in the middle on who-knows-where on some forgotten reservation, where Native Americans are tucked away out of sight, out of mind. And then the unthinkable happens! Earth becomes prey to the galaxy's largest predator, a space bound Texas-sized alien that's looking to satiate its hunger with the organic goodness that most populates Earth: Us. And the first course is a certain forgotten reservation. A Spiritual Awakening Tommy and his girlfriend have become prey, his grandfather killed, and hundreds of his tribal nation have been abducted through space-warping portals. Freeing himself, all Tommy cares about is saving Jenny. But the spirit of his grandfather beckons him to embrace his heritage, accept the ancient teachings, and prepare to battle the menace that threatens to destroy all the planet's life. It's a choice between love and responsibility.

Post tutorial Report RSS Gravity Volumes tutorial

This is a tutorial on how to make a gravity volume. Similar to the sphere the player teleports into.

Posted by on - Advanced Mapping/Technical

Originally written by 3D Realms and was previously available on their developer wiki. Mirrored here for archival purposes.

Note this tutorial's sample level is downloadable here.


Gravity Volumes Tutorial

Setting up a simple gravity volume.

Drag out a brush that defines the extents of your volume. Right click on the created brush and choose volume_gravity from the popup menu.

Gravity1
Fig.1: Right click menu

Select the newly created volume_gravity entity and enter a key named 'gravity' to define the direction of the gravity field within the volume. This is a vector key defining gravity strength in X, Y and Z. Standard game gravity is '0 0 -1066'; that is, a force of 1066 in the negative Z direction. The figure below shows a normal gravity volume setup, download and open the grav1.map test map to see an example.

Image:Gravity2.jpg
Fig.2: A standard gravity_volume with inverted gravity.

Changing the state of a gravity volume.

The state of a gravity volume can be altered in two ways. A target_enable and target_disable entity can be used to turn the effect of a volume on and off. Additionally more precise control is available within the level script.

For our example here we will just toggle the state of the volume. In the example map we use a console_projection_eye to allow us to alter the volume, but any standard triggering method will work. Download and examine grav2.map to see how it is set up.

Image:Gravity3.jpg
Fig.3: Using consoles to enable and disable a gravity volume.

Note: There's an undocumented key available on gravity volumes. The key 'enabled' can be set to 0 to prevent a volume being active at map load. More advanced control is available in the form of the script call $entityname.setGravity( vector );

Shoot switches.

Using shoot switches (entity name 'trigger_gravityswitch') to change the state of a gravity volume is very easy. Place a trigger_gravityswitch with an orientation that reflects the direction you wish your new gravity to assume. Have the switch target your gravity_volume and the details are taken care of by the game. In the example map (grav3.map) four switches are placed in four sides of the gravity volume, all the map maker needs do in this case is have each switch target the volume.

Image:Gravity4.jpg
Fig.4: Shoot switches targeting a gravity volume.

It is possible to override this behavior by setting the 'vector' key on the switch. This was not done in Prey as it was felt important to have the switches behave consistently.

Radial gravity.

For planetoids we use a different entity, a 'volume_gravityinward'. The illustration below (taken from grav4.map) shows a simple planetoid using a default volume_gravityinward. No other keys are required in order to set this up, although fine tuning of the behavior is possible using the keys documented in the appendix below.

Image:Gravity5.jpg
Fig.5: Side view of a basic radial gravity volume allowing the player to walk on a planetoid.

Outward gravity.

Although not used in the single player portion of Prey it is possible to use a negative factor with a radial gravity volume. In example map grav5.map the following key was used to allow the player to walk on the inside of a spherical space.

Image:Gravity6.jpg
Fig.6: Using a negative factor to allow the player to walk in the inside of a sphere.

Image:Gravity7.jpg
Fig.7: Top down editor view of an outward gravity volume.

Performance considerations.

Things to bear in mind when designing a gravity rich area.

Use broad strokes to define your gravity volumes. Each additional volume placed in the map adds to the computational overhead. Avoid using many small volumes to fit the layout of your area and blanket large parts with a single volume if at all possible.

“isSimpleBox” is an important key. It defaults true because a non simple volume adds considerable overhead when calculating the behavior required. You will undoubtedly need to set this false on occasion but try to design around it if at all possible.

Don't underestimate the use of smoke and mirrors. Clever use of a portal or a wall walk surface can trick the player into believing they are in an altered gravity area. It's always cheaper to invert the geometry and use standard gravity than to use a gravity_volume.

AI creatures will respond better to a standard gravity orientation so again, think of ways to trick the player if you plan combat in an area of gravity madness.

Appendix.

Screenshot 2024 02 16 213618

Post a comment

Your comment will be anonymous unless you join the community. Or sign in with your social account: