Skip to end of metadata
Go to start of metadata


Overview

Sections

After completing this tutorial, you will be able to set up a simple mission, define the starting point of the level, assign one objective, and a load next level trigger.

The more non-linear the mission objectives are, the more time you need to spend testing them. It is therefore recommended that beginners make a linear gameplay path to start with: 1st objective, complete triggers, 2nd objective, and triggers mission end.


Adding a Spawn Point

Under the Create Object -> Entity -> Others, drag the SpawnPoint entity to a point in the Perspective viewport.

Pic1: Creating a Spawnpoint

It is generally a good idea to use Flow Graph to script the game to spawn the player at the spawn point. Otherwise when you run the Launcher, you can be spawned at the 0,0,0 location coordinates within the level.

To make the Spawn Point work, select it and right-click on it. Then choose Create Flow Graph and give it a logical name, like "SpawnPoint".

Then right-click in the Flowgraph and choose Add Node -> Game -> Start. Next, make sure you have the Spawn Point selected, right-click on an empty space and choose Add Selected Entity.

Now all you need to do is click and hold the output port of the Start node and drag the appearing arrow to the Spawn port of the SpawnPoint node.

Pic2:  Using Flowgraph to script the game's Spawn Point


The reason this is not automated is levels can have multiple spawn points, like one at every checkpoint, for example. So you need to define where you want the player to spawn and when.

Triggering Events

Proximity Triggers

You can use triggers to activate various actions in the Editor. This tutorial covers two main ones: Proximity Triggers and Area Triggers. You can drag triggers also to the Perspective viewport.

Pic3: ProximityTrigger location

You can double-click or drag and place this trigger in your level. It will be displayed as a T icon with a yellow box around it:

Pic4: Proximity Trigger placed
 

When you select the Proximity Trigger, you can change its properties in the Properties tool:

Pic5: Proximity Trigger properties

 

There are numerous things you can set up here, like the size of the area in which it's triggered (DimXDimYDimZ), whether it can only triggered by AI (OnlyAI), the player (OnlyMyPlayer) etc., or if it can only be triggered once (TriggerOnce).

Placing an Area Trigger

An AreaTrigger is split into 2 parts, the Area Shape and the Area Trigger Entity. The Trigger is placed from the Create Object tab.

First go to the Create Object tool (Entities -> Triggers -> AreaTrigger) and place one down in the level.

Then create a Shape using the Area tool found in the Create Object tool (Area -> Shape), and draw out a shape by clicking at four different spots and double-clicking the last spot to close the shape.

You can add as many points in as you want to define the exact shape of the triggers activation area, but it doesn't have to be super detailed, simply approximate the shape.

Make sure Snapping to Geometry is turned on before drawing your shape, as otherwise it might be drawn vertically instead of on the terrain.

Pic6: Creating a Shape using the Area tool

Pic7: Area Shape drawn
 

Next place down an area trigger from Create Object -> Entity -> Triggers -> Area Trigger and assign the AreaTrigger to the shape.
You do this by selecting the shape, clicking the button next to EntityLinks in the Properties and choosing Add:

Pic8: Adding an EntityLink
 

When you've done this, a box will appear under the EntityLinks header. Click on this box and it will read "Pick an Entity...". All you have to do now is click on the AreaTrigger you have created earlier and the shape and AreaTrigger will be linked:

Pic9: Picking the AreaTrigger

Unlike Proximity Triggers, Area Triggers have no boundary to speak of. They are simply logical triggers. To use Area Triggers, you must link a shape to them to so they can work.

Area Shapes when created are a flat plane. Technically this means that the "activation area" of that shape is infinite in the Z axis. This is OK for most situations, unless you have a multi-floor setup where you only want to activate it on the ground floor.

To restrict this infinite Z axis on an Area Shape, we can assign a height to the shape from within its properties. To do this, change the DimZ property in its Entity Properties:

Pic10: Changing the height of a Proximity Trigger
 

This will then cap the height of the shape into a defined volume. X and Y is defined by the area shape and the height defines the limit of the Z axis.

When creating Proximity or Area Triggers, it's good practice to sink them slightly into the floor. This is to ensure activation of the trigger, as the player's reference point (Gizmo) is located between his feet.

Adding Logic to Triggers

Creating a Flow Graph

To define what a trigger should do, a Flow Graph needs to be created. Select the AreaTrigger we just created, and then click Open in the FlowGraph section of the Entity Properties in the Properties tool, or right-click the AreaTrigger in the viewport and select Create Flow Graph.

Pic11: Creating a Flow Graph

Specify a group name for the Flow Graph by clicking New... or by adding it to an existing group in the list. It is good practice to organize the level in layers, and then give the Flow Graph a name that contains the layer it mainly affects.

We will create a new group called Mission.

Pic12: Creating a new group

For more information, please see the documentation on using the How to Use Flow Graph.

Adding an Entity to the Flow Graph

First make sure that the AreaTrigger is selected in the Sandbox Editor. Then, in the FlowGraph window, right-click in the empty field in the middle and select Add Selected Entity.

Pic13: Adding AreaTrigger node in Flow Graph

Make sure that the AreaTrigger node can be seen, by zooming in with the mouse wheel or by right-clicking in an empty space in the Flow Graph and choosing Fit Graph To View:

Pic14: Fitting the Graph to view

The AreaTrigger node has the input events on the left side and the output events on the right side.

Adding a Mission Objective

Drag the MissionObjective entity to a place in the level where the player should go to.

Pic15: MissionObjective location
 

Pic16: MissionObjective dragged into the level
 

Open the FlowGraph that you previously created, and then select the MissionObjective entity in the Perspective view.

Now, add the MissionObjective to the FlowGraph by right-clicking the FlowGraphs main window and selecting Add Selected Entity.

Connecting Entities in the FlowGraph

Now, move the MissionObjective object to the right of the AreaTrigger by clicking and dragging the object frame.

Once it is in place, left click and hold the Enter port in the AreaTrigger and drag the mouse to the Activate port in the MissionObjective:

Pic17: Connecting AreaTrigger node to MissionObjective node

The Mission Objective has several important inputs:

Input

Description

Activate

0 means objective is not activated and 1 mean it is activated.

Completed

Marks an objective in the PDA as completed.

Deactivate

Removes an objective from the PDA.

Failed

Marks an objective in the PDA as failed.

Loading a New Mission

Once the player has finished his objective, let's load the next level (obviously you could trigger another objective after the first one, but for this test, simply load the next level. Any random level will do, for example Woodland if you have downloaded the CRYENGINE GameSDK Sample Project from the Marketplace).

  1. Place a ProximityTrigger over the MissionObjective node.
  2. Add the ProximityTrigger node to the Flow Graph.
  3. Connect the Enterout port of the ProximityTrigger with the Completedin port of the MissionObjective.
  4. Add a Delay node, double-click on its Delay property and set a delay of 3 seconds.
  5. Now, add a Mission -> LoadNextLevel node.
  6. Connect the Completedout port of the MissionObjective to the In of the Delay, then connect the out of the Delay to the inputTrigger port of the LoadNextLevel node.
  7. Select the LoadNextLevel node and specify the name of the level that should be loaded in the Inputs field (Woodland).

Pic18: Loading a new mission using FlowGraph

Result

When the player enters the Area Trigger, this activates the mission objective (top).

Then when the player walks into the Proximity Trigger (on enter output), this completes the mission and the next mission will be loaded after 3 seconds.

If you press L (default key) for the mission objective HUD, you can see the missions come into your HUD and get updated when completed.

This (level loading command) works only in true game mode - the Editor will not load the next level.

You will get a warning in the console instead:

[SANDBOX: Warning] CCryAction: Suppressing loading of next level 'levelname' in Editor

  • No labels