CryENGINE 3: Sandbox Basics

0
120
8 min read

 

CryENGINE 3 Cookbook

CryENGINE 3 Cookbook

Over 100 recipes written by Crytek developers for creating AAA games using the technology that created Crysis 2

Placing the objects in the world

Placing objects is a simple task; however, basic terrain snapping is not explained to most new developers. It is common to ask why, when dragging and dropping an object into the world, they cannot see the object. This section will teach you the easiest ways to place an object into your map by using the Follow Terrain method.

Getting ready

  1. Have My_Level open inside of Sandbox (after completing either of the Terrain sculpting or Generating a procedural terrain recipes).
  2. Review the Navigating a level with the Sandbox Camera recipe to get familiar with the Perspective View.
  3. Have the Rollup Bar open and ready.
  4. Make sure you have the EditMode ToolBar open (right-click the top main ToolBar and tick EditMode ToolBar).

How to do it…

First select the Follow Terrain button. Then open the Objects tab within the Rollup Bar. Now from the Brushes browser, select any object you wish to place down (for example, defaults/box).

You may either double-click the object, or drag-and-drop it onto the Perspective View. Move your mouse anywhere where there is visible terrain and then click once more to confirm the position you wish to place it in.

How it works…

The Follow Terrain tool is a simple tool that allows the pivot of the object to match the exact height of the terrain in that location. This is best seen on objects that have a pivot point close to or near the bottom of them.

There’s more…

You can also follow terrain and snap to objects. This method is very similar to the Follow Terrain method, except that this also includes objects when placing or moving your selected object.

This method does not work on non-physicalized objects.

 

Refining the object placement

After placing the objects in the world with just the Follow Terrain or Snapping to Objects, you might find that you will need to adjust the position, rotation, or scale of the object. In this recipe, we will show you the basics of how you might be able to do so along with a few hotkey shortcuts to make this process a little faster. This works with any object that is placed in your level, from Entities to Solids.

Getting ready

  1. Have My_Level open inside of Sandbox
  2. Review the Navigating a level with the Sandbox Camera recipe to get familiar with the Perspective View.
  3. Make sure you have the EditMode ToolBar open (right-click on the top main ToolBar and tick EditMode ToolBar).
  4. Place any object in the world.

How to do it…

In this recipe, we will call your object (the one whose location you wish to refine) Box for ease of reference.

  1. Select Box.
  2. After selecting Box, you should see a three axis widget on it, which represents each axis in 3D space. By default, these axes align to the world:
    • Y = Forward
    • X = Right
    • Z = Up

To move the Box in the world space and change its position, proceed with the following steps:

  1. Click on the Select and Move icon in the EditMode ToolBar (1 for the keyboard shortcut).
  2. Click on the X arrow and drag your mouse up and down relative to the arrow’s direction.
  3. Releasing the mouse button will confirm the location change.

You may move objects either on a single axis, or two at once by clicking and dragging on the plane that is adjacent to any two axes: X + Y, X + Z, or Y + Z. To rotate an object, do the following:

  1. Select Box (if you haven’t done so already).
  2. Click on the Select and Rotate icon in the EditMode ToolBar (2 for the keyboard shortcut).
  3. Click on the Z arrow (it now has a sphere at the end of it) and drag your mouse from side to side to roll the object relative to the axis.
  4. Releasing the mouse button will confirm the rotation change.

You cannot rotate an object along multiple axes. To scale an object, do the following:

  1. Select Box (if you haven’t done so already).
  2. Click on the Select and Scale icon in the EditMode ToolBar (3 for the keyboard shortcut).
  3. Click on the CENTER box and drag your mouse up and down to scale on all three axes at once.
  4. Releasing the mouse button will confirm the scale change.

It is possible to scale on just one axis or two axes; however, this is highly discouraged as Non-Uniform Scaling will result in broken physical meshes for that object. If you require an object to be scaled up, we recommend you only scale uniformly on all three axes!

There’s more…

Here are some additional ways to manipulate objects within the world.

Local position and rotation

To make position or rotation refinement a bit easier, you might want to try changing how the widget will position or rotate your object by changing it to align itself relative to the object’s pivot. To do this, there is a drop-down menu in the EditMode ToolBar that will have the option to select Local. This is called Local Direction.

This setup might help to position your object after you have rotated it.

Grid and angle snaps

To aid in positioning of non-organic objects, such as buildings or roads, you may wish to turn on the Snap to Grid option. Turning this feature on will allow you to move the object on a grid (currently relative to its location). To change the grid spacing, click the drop-down arrow next to the number to change the spacing (grid spacing is in meters).

Angle Snaps is found immediately to the right of the Grid Snaps. Turning this feature on will allow you to rotate an object by every five degrees.

Ctrl + Shift + Click

Even though it is a Hotkey, to many developers this hotkey is extremely handy for initial placement of objects. It allows you to move the object quickly to any point on any physical surface relative to your Perspective View.

 

Utilizing the layers for multiple developer collaboration

A common question that is usually asked about the CryENGINE is how does one developer work on the same level as another at the same time. The answer is—Layers. In this recipe, we will show you how you may be able to utilize the layer system for not only your own organization, but to set up external layers for other developers to work on in parallel.

Getting ready

  1. Have My_Level open inside of Sandbox.
  2. Review the Navigating a level with the Sandbox Camera to get familiar with the Perspective View.
  3. Have the Rollup Bar open and ready.
  4. Review the Placing the objects in the world (place at least two objects) recipe.

How to do it…

  1. For this recipe, we will assume that you have your own repository for your project or some means to send your work to others in your team.
  2. First, start by placing down two objects on the map. For the sake of the recipe, we shall refer to them as Box1 and Box2. After you’ve placed both boxes, open the Rollup Bar and bring up the Layers tab.
  3. Create a new layer by clicking the New Layer button (paper with a + symbol).
  4. A New Layer dialog box will appear. Give it the following parameters:
    • Name = ActionBubble_01
    • Visible = True
    • External = True
    • Frozen = False
    • Export To Game = True
  5. Now select Box1 and open the Objects tab within the Rollup Bar.
  6. From here you will see in the main rollup of this object with values such as – Name, Helper Size, MTL, and Minimal Spec. But also in this rollup you will see a button for layers (it should be labelled as Main). Clicking on that button will show you a list of all other available layers.
  7. Clicking again on another layer that is not highlighted will move this object to that layer (do this now by clicking on ActionBubble_01).
  8. Now save your level by clicking—File | Save.

Now in your build folder, go to the following location: –… GameLevelsMy_Level. From here you will notice a new folder called Layers. Inside that folder, you will see ActionBubble_01.lyr.

This layer shall be the layer that your other developers will work on. In order for them to be able to do so, you must first commit My_Level.cry and the Layers folder to your repository (it is easiest to commit the entire folder).

After doing so, you may now have your other developer make changes to that layer by moving Box1 to another location. Then have them save the map.

Have them commit only the ActionBubble_01.lyr to the repository. Once you have retrieved it from the updated repository, you will notice that Box1 will have moved after you have re-opened My_Level.cry in the Editor with the latest layer.

How it works…

External layers are the key to this whole process. Once a .cry file has been saved to reference an external layer, it will access the data inside of those layers upon loading the level in Sandbox.

It is good practice to assign a Map owner who will take care of the .cry file. As this is the master file, only one person should be in charge of maintaining it by creating new layers if necessary.

There’s more…

Here is a list of limitations of what external layers cannot hold.

External layer limitations

Even though any entity/object you place in your level can be placed into external layers, it is important to note that there are some items that cannot be placed inside of these layers. Here is a list of the common items that are solely owned by the .cry file:

  • Terrain
    • Heightmap
    • Unit Size
    • Max Terrain Height
    • Holes
    • Textures
  • Vegetation
  • Environment Settings (unless forced through Game Logic)
    • Ocean Height
  • Time of Day Settings (unless forced through Game Logic)
  • Baked AI Markup (The owner of the .cry file must regenerate AI if new markup is created on external layers)
  • Minimap Markers

 


Subscribe to the weekly Packt Hub newsletter

* indicates required

LEAVE A REPLY

Please enter your comment!
Please enter your name here