Creating a Flowgraph

From CryWiki

Jump to: navigation, search
About
Skill Level Beginner
Compatibility Original

The next step after creating a map is creating dynamic behaviour, or actions and events in the game. To do this, we can use the flowgraph tool; this is in effect a easy-to-learn simplistic but infinitely powerful scripting tool that can be used to set up all kinds of behaviours, events and actions in game. In this tutorial, in order to master some of the basics of the flowgraph, you will learn how to give a weapon to the player when the player is near to an object using the Flowgraph.

Contents

Prerequisites

Creating a Trigger

Step 1. Drop a Proximity Trigger onto the map.

This entity will be used to trigger our flowgraph. To spawn a ProximityTrigger, go to Rollup Bar > Create > Entity > Triggers > Proximity Trigger.


Step 2. Select the trigger and click the "Create" button in the Flow Graph section just below the trigger's properties.

Image:Create_button.png


Step 3. A new window will pop up asking you to name the new graph. Choose any name you can easily remember. When you're finished, click OK.

After creating and naming the flowgraph, the Flow Graph Editor will pop up. You will notice that the name you gave your flowgraph is now listed below the name of your Proximity Trigger on the left-hand side of the screen in the Flow Graphs window.

Image:editor_window_overview.png

A brief description of each window:

Components
Here you will find a list of all the available Nodes you can use in your Graphs.
Flow Graphs
Here you will find a list of all Graphs contained in your level.
Entity
Here you will be able to adjust the values of the Input ports for the selected Node. You can also view the description of the selected Node, or adjust the properties of the Graph.
Search
Here you can quickly search through your graphs for different criteria.
Search Results
Here you can find the results of your searches.

Creating a Flowgraph Node

There are two ways to create a Node in your graph. By right-clicking anywhere in the checkboard window, you can:

  1. Select the “Add Graph Default Entity” option to create a node that represents the graph’s default entity.
  2. Select the “Add Selected Entity” option to create a node that represents the currently-selected entity in the Editor.


Step 4. With your Proximity Trigger still selected, go to the “Add Selected Entity” option.

Image:add_selected_entity.png


A tiny black spot will appear near where you right-clicked in the checkboard window. Don’t worry, you didn’t burn a pixel out in your LCD. That is actually the Node you just created. It’s not small; you’re just zoomed out really, really far!

Step 5. Zoom In by placing the mouse cursor on top of the black spot and scrolling mouse wheel up.

Eventually, the window will come into view and you will be able to make out what it is.

The arrows on the node represent ports. The ones on the left are your Input or “Coming In” ports. The ones on the right are your Output or “Going out” ports. The basic rule of thumb is:

  1. You signal or call an Input Port.
  2. The Node will execute some sort of logic.
  3. The result of the execution will trigger one or more Output Ports.
  4. You connect the Output Port to another node’s Input Port to signal it.
Step 6. Right click anywhere in the checkboard window and place the “Inventory:AddItem” node. You can find this in the “Add Node” menu. (Add Node -> Inventory -> AddItem)

Image:add_item.png

What we are did here is give the player a Shotgun when they walk into our Proximity Trigger. So we dropped a node that will let us adjust the player’s Inventory.

Adjusting Input Values

Step 7. Click on the "Item" entry in the Inputs window and select the "Shotgun" item from the dropdown box.

Image:Adjust_input_values.png


This tells the Inventory:AddItem node what weapon we wanted to give to the player. Values in the Inputs window represent the values for the respective Input Port. Almost all Nodes have Input values that let you alter how the Node works. To adjust them is always the same: find them in the Inputs window, and type in or select the value you wish to use.

Creating Links

Once the value has been selected, all we need to do is signal the Inventory:AddItem Node’s add Input Port to give the player the shotgun! We will signal this port from the Proximity Trigger’s Enter Output Port.

Step 8. Click and drag from the "Enter" output port on the Proximity Trigger node to the "add" input port on the Inventory.AddItem node.

Image:Click_drag_release.png

You should see a curvy line with an arrow connecting the two ports.

Image:Click_drag_release_result.png

Conclusion

That’s it! You just defined your first Link. To recap, your Graph now has two Nodes: one for the Proximity Trigger in your world, and one that lets you add items to the player’s Inventory. You defined a Link connecting the Proximity Trigger Node’s Enter Input Port to the Inventory:AddItem Node’s add Output Port.

When you walk into the Proximity Trigger in the game, you will be given a shotgun! Try it out, and continue experimenting! There are more things the Flow Graph Editor is capable of doing that were not mentioned in this tutorial.

See Also

Flowgraph

Node

Personal tools