Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
CryENGINE Game Programming with C++, C#, and Lua
CryENGINE Game Programming with C++, C#, and Lua

CryENGINE Game Programming with C++, C#, and Lua: For developers wanting to create 3D games, CryENGINE offers the intuitive route to success and this book is the complete guide to using it. Learn to use sophisticated tools and build super-real, super-addictive games.

eBook
AU$14.99 AU$53.99
Paperback
AU$67.99
Subscription
Free Trial
Renews at AU$24.99p/m

What do you get with a Packt Subscription?

Free for first 7 days. $24.99 p/m after that. Cancel any time!
Product feature icon Unlimited ad-free access to the largest independent learning library in tech. Access this title and thousands more!
Product feature icon 50+ new titles added per month, including many first-to-market concepts and exclusive early access to books as they are being written.
Product feature icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Product feature icon Thousands of reference materials covering every tech concept you need to stay up to date.
Subscribe now
View plans & pricing
Table of content icon View table of contents Preview book icon Preview Book

CryENGINE Game Programming with C++, C#, and Lua

Chapter 2. Visual Scripting with Flowgraph

The CryENGINE flowgraph is a powerful node-based visual scripting system, aiding developers in rapidly prototyping features and creating level specific logic without having to work with complicated codebases.

In this chapter, we will:

  • Discuss the concept of flowgraphs
  • Create new flowgraphs
  • Debug our flowgraph
  • Create a custom flowgraph node (flownode) in Lua, C#, and C++

Concept of flowgraphs

For years, writing code has been the primary, if not the exclusive method of creating behaviors and logic for games. Let's take the example of a level designer, building a combat section for the latest title.

Traditionally, the said designer would have to ask a programmer to create the logic for this scenario. This has several problems:

  • It creates a disconnect between the design and the implementation
  • Programmers are forced into spending time which is really a designer's job
  • The designer has no immediate feedback on how his/her section plays out

This is the problem that CryENGINE's flowgraph, often referred to as FG, solves. It provides a set of flownodes, best thought of as convenient Lego blocks of logic, which the designer can utilize to piece together entire scenarios. No more requests to the game code team; designers can go ahead and realize their ideas instantly! We'll discuss creating the nodes themselves in more detail later, but for now, let...

Opening the Flowgraph Editor

To get started, we need to open up Sandbox. Sandbox contains the Flowgraph Editor as one of its many useful tools, and it can be opened via View | Open View Pane.

Note

You should always have a level loaded when opening the Flowgraph Editor, as flowgraphs are unique to levels. Flick back to Chapter 1, Introduction and Setup, if you've forgotten how to create a new level!

Opening the Flowgraph Editor

You've just accessed your first Sandbox tool! You should be presented with a new window with lots of subsections and features, but don't fret, let's tackle them one by one.

A tour of the Flowgraph Editor

Flowgraphs are saved on the disk as XML files, but can be parsed and edited by the Flowgraph Editor in order to provide a visual interface to the process of creating game logic.

A tour of the Flowgraph Editor

Components

This section of the Editor contains all the flownodes in your project, organized into neat categories. Let's take a quick look inside this, open up the Misc folder. You should be presented with a set of nodes, assigned to categories:

Components

Terminology

  • Graph: This refers to a context containing a set of nodes linked to each other.
  • Node: This is a visual representation of a class that can receive data and events from its input ports, as well as send data via its output ports. It is connected to other nodes in graphs to create logic.
  • Port: This is a visual representation of a function. Nodes can specify multiple input and output ports, and can then send or receive events from them.

Component categories

You may be missing the node marked as Debug here; CryENGINE assigns categories to...

Creating a flowgraph

Now that we have a basic understanding of how the Flowgraph Editor works, let's dive right in and create our first flowgraph! You can close the Flowgraph Editor for the moment.

The flowgraph entity

The flowgraph entity is an extremely lightweight CryENGINE object, designed to be used when you need a flowgraph that isn't applied to any specific entity. Like all entities, it can be found in RollupBar inside Sandbox.

Note

If you're not sure what an entity is, skip this section until you have read Chapter 3, Creating and Utilizing Custom Entities.

The flowgraph entity

Spawning FlowgraphEntity

Select FlowgraphEntity and then either double-click and click again on the viewport, or click and drag it into the level. You should now see a whole new set of options in RollupBar, including entity params, material layers, but mostly important for us, the Entity: FlowgraphEntity section.

Attaching a new flowgraph

Inside the Entity: FlowgraphEntity section, we need to find the Flow Graph subsection...

Concept of flowgraphs


For years, writing code has been the primary, if not the exclusive method of creating behaviors and logic for games. Let's take the example of a level designer, building a combat section for the latest title.

Traditionally, the said designer would have to ask a programmer to create the logic for this scenario. This has several problems:

  • It creates a disconnect between the design and the implementation

  • Programmers are forced into spending time which is really a designer's job

  • The designer has no immediate feedback on how his/her section plays out

This is the problem that CryENGINE's flowgraph, often referred to as FG, solves. It provides a set of flownodes, best thought of as convenient Lego blocks of logic, which the designer can utilize to piece together entire scenarios. No more requests to the game code team; designers can go ahead and realize their ideas instantly! We'll discuss creating the nodes themselves in more detail later, but for now, let's take a look at some...

Opening the Flowgraph Editor


To get started, we need to open up Sandbox. Sandbox contains the Flowgraph Editor as one of its many useful tools, and it can be opened via View | Open View Pane.

Note

You should always have a level loaded when opening the Flowgraph Editor, as flowgraphs are unique to levels. Flick back to Chapter 1, Introduction and Setup, if you've forgotten how to create a new level!

You've just accessed your first Sandbox tool! You should be presented with a new window with lots of subsections and features, but don't fret, let's tackle them one by one.

A tour of the Flowgraph Editor


Flowgraphs are saved on the disk as XML files, but can be parsed and edited by the Flowgraph Editor in order to provide a visual interface to the process of creating game logic.

Components

This section of the Editor contains all the flownodes in your project, organized into neat categories. Let's take a quick look inside this, open up the Misc folder. You should be presented with a set of nodes, assigned to categories:

Terminology

  • Graph: This refers to a context containing a set of nodes linked to each other.

  • Node: This is a visual representation of a class that can receive data and events from its input ports, as well as send data via its output ports. It is connected to other nodes in graphs to create logic.

  • Port: This is a visual representation of a function. Nodes can specify multiple input and output ports, and can then send or receive events from them.

Component categories

You may be missing the node marked as Debug here; CryENGINE assigns categories to nodes...

Creating a flowgraph


Now that we have a basic understanding of how the Flowgraph Editor works, let's dive right in and create our first flowgraph! You can close the Flowgraph Editor for the moment.

The flowgraph entity

The flowgraph entity is an extremely lightweight CryENGINE object, designed to be used when you need a flowgraph that isn't applied to any specific entity. Like all entities, it can be found in RollupBar inside Sandbox.

Note

If you're not sure what an entity is, skip this section until you have read Chapter 3, Creating and Utilizing Custom Entities.

Spawning FlowgraphEntity

Select FlowgraphEntity and then either double-click and click again on the viewport, or click and drag it into the level. You should now see a whole new set of options in RollupBar, including entity params, material layers, but mostly important for us, the Entity: FlowgraphEntity section.

Attaching a new flowgraph

Inside the Entity: FlowgraphEntity section, we need to find the Flow Graph subsection, and then click...

The stock flownode overview


To make something a little more complex, we're going to need an understanding of what nodes the CryENGINE provides for us by default.

Building a clock

One of the most useful nodes we have access to, at least for debugging purposes, is the HUD:DisplayDebugMessage node. It allows you to display information in the game window, optionally with a timeout. With that in mind, let's build a little debug clock based on the time information we learnt about earlier.

The Time:TimeOfDay node outputs the current time in the CryENGINE time format, which is defined as hours plus minutes divided by 60. For example, 1:30 p.m. would be expressed as 13.5 in CryENGINE time. We now know we're going to need some mathematical operations, so it's time to check the Math flownode category.

The first thing we'll do is get the time in hours by rounding the current time down. To do this, place Math:Floor, then connect the CurTime output from our Time:TimeOfDay node to Floor's A input port. Then...

Flowgraph modules


The flowgraph module system allows flowgraphs to be exported as a module that can be triggered from another graph.

By creating modules, we can reuse logic in multiple levels without having to maintain several versions of the same graph. It's also possible to send and receive unique data to and from the modules, allowing dynamic logic in a very modular manner.

Creating a module

To start with creating your own module, open the Flowgraph Editor and select File | New FG Module... | Global:

In the resulting Save dialog box, save the module with a name of your choice. You'll then be shown the default view of a module:

The module contains two nodes by default; Module:Start_MyModule and Module:End_MyModule.

  • Module:Start_MyModule contains three output ports:

    • Start: This is called when the module is loaded

    • Update: This is called when the module should be updated

    • Cancel: This is called when the module should cancel, and it is connected to the Cancel input of Module:End_MyModule by default...

Left arrow icon Right arrow icon

Key benefits

  • Dive into the various CryENGINE subsystems to quickly learn how to master the engine
  • Create your very own game using C++, C#, or Lua in CryENGINE
  • Understand the structure and design of the engine

Description

CryENGINE is a complete 3D game development solution that can run on multiple platforms. It is orientated around giving intuitive tools to the developer. A variety of interactive video games can be created using CryENGINE. CryENGINE is one of the most beginner-friendly engines out there to learn. If you are interested in diving into the various systems and understanding their workings in a way that is easily understood, then this book is for you. This book provides you with the knowledge to tame the powerful but hard-to-master CryENGINE. CryENGINE Game Programming with C++, C#, and Lua dives into the various systems and explains their workings in a way that can be easily understood by developers of all levels. It provides knowledge on the engine along with step-by-step exercises and detailed information on the backend implementation of the subsystems, giving you an excellent foundation to build upon when developing your own CryENGINE games. Written by developers with years of CryENGINE experience, this book breaks down the common confusion that encompasses the CryENGINE engine code, guiding you through a series of chapters aimed towards giving you the ability to create your own games in a rapid yet productive fashion. You will learn everything you need to know in order to create your own CryENGINE-powered games as well as detailed information on how to use the engine to your advantage. By teaching systems such as audio, particle effects, rendering, AI, networking, and more, we'll be exposing the most inner parts of CryENGINE that commonly confuse programmers. If you want to quickly gain the knowledge required to create your own CryENGINE game title, then this book is for you.

Who is this book for?

This book is intended for developers looking to harness the power of CryENGINE, providing a good grounding in how to use the engine to its full potential. The book assumes basic knowledge of the engine and its editor in non-programming areas.

What you will learn

  • Make and modify Flowgraph nodes to give your visual scripting a clear advantage
  • Utilize custom entities, from simple physicalized objects to complex weather simulation managers
  • Control the flow of the game in real-time by creating game rules and modes
  • Create custom actors, in order to create unique elements controllable by human players
  • Use the Artificial Intelligence system to your advantage with custom AI units
  • Design custom User Interfaces to give your player a way to navigate the game s menus and HUDs
  • Implement multiplayer and networking elements for your game, allowing several players to share the experience with each other
  • Master game physics and how to create your own physicalized objects that can interact with the game world
  • Understand the process of using and manipulating the CryENGINE renderer to your advantage, including custom shader authoring
  • Bring your game to life by introducing effects such as particles and sound
  • Debug and profile your game code to get the most out of the computers running your game
  • Implement stock GameDll systems such as vehicles and weapons

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Nov 22, 2013
Length: 276 pages
Edition : 1st
Language : English
ISBN-13 : 9781849695909
Vendor :
Crytek
Languages :
Concepts :
Tools :

What do you get with a Packt Subscription?

Free for first 7 days. $24.99 p/m after that. Cancel any time!
Product feature icon Unlimited ad-free access to the largest independent learning library in tech. Access this title and thousands more!
Product feature icon 50+ new titles added per month, including many first-to-market concepts and exclusive early access to books as they are being written.
Product feature icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Product feature icon Thousands of reference materials covering every tech concept you need to stay up to date.
Subscribe now
View plans & pricing

Product Details

Publication date : Nov 22, 2013
Length: 276 pages
Edition : 1st
Language : English
ISBN-13 : 9781849695909
Vendor :
Crytek
Languages :
Concepts :
Tools :

Packt Subscriptions

See our plans and pricing
Modal Close icon
AU$24.99 billed monthly
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
AU$249.99 billed annually
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just AU$5 each
Feature tick icon Exclusive print discounts
AU$349.99 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just AU$5 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total AU$ 219.97
CryENGINE 3 Cookbook
AU$75.99
CryENGINE 3 Game Development: Beginner's Guide
AU$75.99
CryENGINE Game Programming with C++, C#, and Lua
AU$67.99
Total AU$ 219.97 Stars icon
Banner background image

Table of Contents

13 Chapters
1. Introduction and Setup Chevron down icon Chevron up icon
2. Visual Scripting with Flowgraph Chevron down icon Chevron up icon
3. Creating and Utilizing Custom Entities Chevron down icon Chevron up icon
4. Game Rules Chevron down icon Chevron up icon
5. Creating Custom Actors Chevron down icon Chevron up icon
6. Artificial Intelligence Chevron down icon Chevron up icon
7. The User Interface Chevron down icon Chevron up icon
8. Multiplayer and Networking Chevron down icon Chevron up icon
9. Physics Programming Chevron down icon Chevron up icon
10. Rendering Programming Chevron down icon Chevron up icon
11. Effects and Sound Chevron down icon Chevron up icon
12. Debugging and Profiling Chevron down icon Chevron up icon
Index Chevron down icon Chevron up icon

Customer reviews

Top Reviews
Rating distribution
Full star icon Full star icon Full star icon Full star icon Half star icon 4.2
(6 Ratings)
5 star 33.3%
4 star 50%
3 star 16.7%
2 star 0%
1 star 0%
Filter icon Filter
Top Reviews

Filter reviews by




Evgeny Adamenkov Mar 09, 2016
Full star icon Full star icon Full star icon Full star icon Full star icon 5
As of today, this is the only book about CryEngine that is useful for programmers, rather than designers.
Amazon Verified review Amazon
Ross Rothenstine Feb 05, 2014
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Having been a part of the CryDev community for a while, using the SDK and tools for personal and college projects, I can safely say this book would have help me out a lot when I first started.The book covers the portions of programming needed to get a game up and running. Entities, Flow Nodes, Actors, Game Rules, and UI development to say a few portions.While the book is aimed at novices to CryEngine, I would recommend a C++ background before picking up this book.
Amazon Verified review Amazon
Brian Feb 28, 2014
Full star icon Full star icon Full star icon Full star icon Empty star icon 4
Very informative, and helps you get into the nitty gritty of the engine.It goes into enough detail to understand how the engine handles everything. With the help of this book I was able to enter a competition for getting an art asset in the game engine. I got into the finals, which is awesome.I would highly recommend the book.
Amazon Verified review Amazon
Nick Feb 07, 2014
Full star icon Full star icon Full star icon Full star icon Empty star icon 4
Both authors, Filip Lundgren (developer for CryMono) and Ruan Pearce-Authers (currently working for Crytek GmbH), have a strong background in working with CryEngine. The book gives a lot of insight into the programming side of the engine, which is mostly missing from the documentation; it’s a great reference for using CryEngine’s subsystems from a programmer’s point of view.The content itself is based on CryEngine 3.5.4, which is one of the latest iterations as of February 2014. There’s also a companion project which is already set up to use CryMono and includes all the code written throughout the chapters. I had some issues running it out of the box but seasoned programmers will have no trouble tackling those problems.The book starts by explaining the building blocks for making your game – how to script your game visually using CryEngine’s flowgraph system and how to create your own custom flow-nodes. It then expands on customizing the entities and game rules in your application. Halfway through the book you’ll already know how to create your level, spawn your actors, control the player camera and add triggers that execute the game logic. This is done in a “learn by example” fashion, which is my personal favorite, especially when the examples are clear and concise as is the case.The second half of the book is dedicated to the major subsystems in the engine – Artificial Intelligence, User Interface, Networking, Physics, Graphics and Sound. At just shy of 300 pages, you can’t expect to gain in-depth knowledge of every little detail in those subsystems from reading the book, but it does give you a comprehensive overview that will get you started. One thing that I did not like was that instead of the example driven style used so far, the book becomes more of a reference in this part, with only one practical example for all the subsystems (namely, “Dynamic alpha testing for vegetation”). The subsystems part of the book does give you a lot of useful information summed up, but I feel that having a few samples would add more value.The last chapter is dedicated to debugging and profiling, covering common ways of detecting and fixing problems in CryEngine.Overall, it’s a great resource for both beginners and intermediate users of CryEngine, although advanced knowledge in general programming is required to understand what’s going on under the hood. That’s why I wouldn't recommend it for novice programmers as they will probably be left frustrated. If you have coding experience and you’re a newcomer to CryEngine who doesn't want to spend hours and hours looking for information, then this book is for you. If you’re already into CryEngine and you find yourself lacking a concise guide for its subsystems it’s worth the read as well.
Amazon Verified review Amazon
Tim Jan 26, 2014
Full star icon Full star icon Full star icon Full star icon Empty star icon 4
Overall, this book is a fount of knowledge regarding programming for CryEngine. The authors examples are both functional and useful. However, this book is clearly for people that have an intermediate coding knowledge. Additionally, it is incredibly helpful to have a working knowledge of the CryEngine SDK before starting this book. I will wholeheartedly admit that my personal knowledge of CryEngine is not the best and that did cause me a few issues in understanding certain things being discussed. If anyone is looking at this book to teach them CryEngine from scratch, there are much better references out there for the complete beginner.There are many subjects, particularly the C++ portions of the book, that help to explain things where the online documentation for the CryEngine SDK is lacking. As such, this book is going to go into my reference library and without a doubt get filled bookmarks and plenty of notes. Though it is impossible to fit all the knowledge of CryEngine into a single volume, this book definitely points the reader in the right direction regarding a good amount of subsystems that CryEngine has to offer a developer. Additionally, the discussion of C# and Lua on top of C++ really shows the freedom that CryEngine can give you.There are some minor issues with some of code that is in the book, but as I said before, familiarity with programming is a must and that knowledge will lead you to easily track down those problems. Formatting of code in ebooks always seems to leave a bit to be desired and there were occasions that I had to look at the code multiple times to get everything right.As I mentioned previously, I would only recommend this book to people with a working knowledge of both CryEngine and generally programming. It is well worth the read for those that need to expand an already existing knowledge base of the game engine.
Amazon Verified review Amazon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

What is included in a Packt subscription? Chevron down icon Chevron up icon

A subscription provides you with full access to view all Packt and licnesed content online, this includes exclusive access to Early Access titles. Depending on the tier chosen you can also earn credits and discounts to use for owning content

How can I cancel my subscription? Chevron down icon Chevron up icon

To cancel your subscription with us simply go to the account page - found in the top right of the page or at https://subscription.packtpub.com/my-account/subscription - From here you will see the ‘cancel subscription’ button in the grey box with your subscription information in.

What are credits? Chevron down icon Chevron up icon

Credits can be earned from reading 40 section of any title within the payment cycle - a month starting from the day of subscription payment. You also earn a Credit every month if you subscribe to our annual or 18 month plans. Credits can be used to buy books DRM free, the same way that you would pay for a book. Your credits can be found in the subscription homepage - subscription.packtpub.com - clicking on ‘the my’ library dropdown and selecting ‘credits’.

What happens if an Early Access Course is cancelled? Chevron down icon Chevron up icon

Projects are rarely cancelled, but sometimes it's unavoidable. If an Early Access course is cancelled or excessively delayed, you can exchange your purchase for another course. For further details, please contact us here.

Where can I send feedback about an Early Access title? Chevron down icon Chevron up icon

If you have any feedback about the product you're reading, or Early Access in general, then please fill out a contact form here and we'll make sure the feedback gets to the right team. 

Can I download the code files for Early Access titles? Chevron down icon Chevron up icon

We try to ensure that all books in Early Access have code available to use, download, and fork on GitHub. This helps us be more agile in the development of the book, and helps keep the often changing code base of new versions and new technologies as up to date as possible. Unfortunately, however, there will be rare cases when it is not possible for us to have downloadable code samples available until publication.

When we publish the book, the code files will also be available to download from the Packt website.

How accurate is the publication date? Chevron down icon Chevron up icon

The publication date is as accurate as we can be at any point in the project. Unfortunately, delays can happen. Often those delays are out of our control, such as changes to the technology code base or delays in the tech release. We do our best to give you an accurate estimate of the publication date at any given time, and as more chapters are delivered, the more accurate the delivery date will become.

How will I know when new chapters are ready? Chevron down icon Chevron up icon

We'll let you know every time there has been an update to a course that you've bought in Early Access. You'll get an email to let you know there has been a new chapter, or a change to a previous chapter. The new chapters are automatically added to your account, so you can also check back there any time you're ready and download or read them online.

I am a Packt subscriber, do I get Early Access? Chevron down icon Chevron up icon

Yes, all Early Access content is fully available through your subscription. You will need to have a paid for or active trial subscription in order to access all titles.

How is Early Access delivered? Chevron down icon Chevron up icon

Early Access is currently only available as a PDF or through our online reader. As we make changes or add new chapters, the files in your Packt account will be updated so you can download them again or view them online immediately.

How do I buy Early Access content? Chevron down icon Chevron up icon

Early Access is a way of us getting our content to you quicker, but the method of buying the Early Access course is still the same. Just find the course you want to buy, go through the check-out steps, and you’ll get a confirmation email from us with information and a link to the relevant Early Access courses.

What is Early Access? Chevron down icon Chevron up icon

Keeping up to date with the latest technology is difficult; new versions, new frameworks, new techniques. This feature gives you a head-start to our content, as it's being created. With Early Access you'll receive each chapter as it's written, and get regular updates throughout the product's development, as well as the final course as soon as it's ready.We created Early Access as a means of giving you the information you need, as soon as it's available. As we go through the process of developing a course, 99% of it can be ready but we can't publish until that last 1% falls in to place. Early Access helps to unlock the potential of our content early, to help you start your learning when you need it most. You not only get access to every chapter as it's delivered, edited, and updated, but you'll also get the finalized, DRM-free product to download in any format you want when it's published. As a member of Packt, you'll also be eligible for our exclusive offers, including a free course every day, and discounts on new and popular titles.