Sandbox Gamelogic

From CryWiki

Sandbox Gamelogic
Jump to: navigation, search

Contents

How to Set Up the Basic Game Logic

Overview

The following walkthrough gives you an overview how to setup a simple mission, defining a place where the level starts, one objective and a load next level trigger.

The more non-linear your mission objectives are, the more time you need to spend testing them, so we recommend for starters to make a linear gameplay path: 1st objective complete triggers 2nd objective, triggers mission end.

Adding a Spawn Point

From the Objects/Entity section of the RollupBar drag from the Others folder the SpawnPoint entity to a point in the perspective viewport.

Image:Sandbox_Gamelogic_image003.png

  1. TriggerEvents

Triggering Events

Proximity Triggers

You can use Triggers to activate various actions in the editor. Here, we will go over 2 main ones – ProximityTriggers and AreaTriggers. You can drag to the perspective viewport Triggers in the usual way in the RollupBar.

Image:Sandbox_Gamelogic_image005.png

Placing an Area Trigger

An AreaTrigger is split into 2 parts, the area and the Trigger. The Trigger is placed in the usual way.

Image:Sandbox_Gamelogic_image007.png

Next create a Shape using the Area tool (found in the RollupBar in the Objects Type sub-menu) by clicking at 4 different spots and double-clicking to close the shape. Assign the AreaTrigger to the Shape using the Pick function while you have the Shape selected.

Image:Sandbox_Gamelogic_image009.png

Adding logic to Triggers

Creating a Flow Graph

To define what a Trigger should do, a Flow Graph needs to be created. Select your Trigger, then click on the Create button in the Flow Graph section of the Entity properties.

Image:Sandbox_Gamelogic_image011.png

Specify a group name for your Flow Graph. It is good practice to organize your level in layers, then give your Flow Graph a name which contains the layer it mainly affects.

Image:Sandbox_Gamelogic_image013.png

Adding an Entity to your Flow Graph

In the Flow Graph window right mouse button click (right-click) the empty field in the middle.

Image:Sandbox_Gamelogic_image015.png

Select Add Selected Entity from right-click menu.

Image:Sandbox_Gamelogic_image017.png

Make sure the ProximityTrigger Node can be seen, by zooming in with the mouse wheel or by setting Fit Graph To View.

Image:Sandbox_Gamelogic_image019.png

The ProximityTrigger Node has on the left side the input events and on the right side the output events.

Image:Sandbox_Gamelogic_image021.png

Adding a Mission Objective

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

Image:Sandbox_Gamelogic_image023.png

Open up the Flow Graph you created previously and then select your MissionObjective Entity in the perspective view.

Now, add the MissionObjective to the Flow Graph by right-clicking in the Flow Graph's main window and selecting Add Selected Entity.

Connecting entities together in Flow Graph

Now, move your MissionObjective object next to the ProximityTrigger by clicking and dragging the object frame.

Once it is it in place, click on the Enter port in your ProximityTrigger, hold the mouse button down, and drag the mouse to the Activate port in your MissionObjective.

Image:Sandbox_Gamelogic_image025.png

The Mission Objective has several other input and outputs:

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
SilentActive: Activates an objective without marking it on the PDA
SilentDeactivate: Deactivates an objective without marking it on the PDA

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 our test, lets load the next level).

1. Place another ProximityTrigger and create another Flow Graph on it.

2. Add the MissionObjective node to this Flow Graph.

3. Connect the Enter out port of your ProximityTrigger with the Completed in port of the MissionObjective.

4. Now, add a Mission/EndLevelNew node.

5. Connect the Completed out port to the trigger port of the EndLevelNew node.

6. Select the EndLevelNew node and specify the name of the level that should be loaded in the Inputs field.

Image:Sandbox_Gamelogic_image027.png

Result

When the player walks into the trigger the next mission is loaded. Note: This only works in real game mode - the Editor will not load the next level.
You will get a warning in the console instead:

<verbatim>[Warning] [[Sandbox_CCryAction|CCryAction]]: Suppressing loading of next level 'levelname' in Editor</verbatim>

See Also

Personal tools