Book Image

CryENGINE 3 Game Development: Beginner's Guide

Book Image

CryENGINE 3 Game Development: Beginner's Guide

Overview of this book

CryENGINE is a complete game development environment used by AAA game development studio Crytek to produce blockbuster games such as Crysis 1, 2 and 3. This complete Beginner's Guide takes the would be game developer through the steps required to create a game world complete with event scripting, user interface and 3D environment in the free CryENGINE SDK. Learn to create game worlds with the CryENGINE 3 Sandbox, the tool used to create AAA games like the soon to be released Crysis 3. Follow straightforward examples to sculpt the terrain, place vegetation, set up lighting, create game sounds, script with Lua and code with C++. Learn to navigate the interface within the CryENGINE 3 Sandbox, the tool used to create AAA games like Crysis 1 and 2, as well as the soon to be released Crysis 3. Learn to create your own worlds by following straight forward examples to sculpt the terrain, place vegetation, set up lighting, create game sounds, and script with the Lua language. The book covers all beginner aspects of game development including an introduction to C++ for non- coders.
Table of Contents (18 chapters)
CryENGINE 3 Game Development Beginner's Guide
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

Time for action - writing a new scriptbind function in C++


In order to be able to execute C++ code from Lua, we need to write a new, so-called Scriptbind function. Scriptbind functions are functions that are exposed to Lua, which means that this C++ function can be called from our Lua script code.

  1. Open the ScriptBind_Actor.h file. You will find all actor-related functions, which are accessible in Lua, as seen in the following screenshot:

  2. If you scroll down, you can simply add a new function there.

  3. So, let's add a new function and name it TeleportTo. Search for SetSearchBeam (which is the last Scriptbind function in this file), and add your new function right under it in the ScriptBind_Actor.h file:

      //teleport the actor to targetPos
      virtual int TeleportTo(IFunctionHandler* pH, Vec3 targetPos);

    Note

    A Scriptbind function always returns an int (number) and gets an IFunctionHandler *pH as the first argument. Each following argument can be user defined. You can add as many arguments as you want...