First, we need to change the lua script. We want to change the function Teleporter:OnUsed to call our C++ function instead of doing the calculation in Lua.
This is pretty easy. Change the function as shown below:
function Teleporter:OnUsed(user) --check „user" being valid if (not user) then return 0; end --compute target position from current position + teleport direction local vCurPos = {}; user:GetWorldPos(vCurPos); local vTargetDir = {}; --assign a temp vector as targetDir „type" vTargetDir.x = self.Properties.teleportDirX; vTargetDir.y = self.Properties.teleportDirY; vTargetDir.z = self.Properties.teleportDirZ; local vTargetPos = vecAdd(vCurPos, vTargetDir); --call the scriptbind function user.actor:TeleportTo(vTargetPos); end
Save your changes of Teleporter.lua.
With the use of user.actor:<function>, we can call all the
Scriptbind
functions that are implemented in ScriptBind_Actor...
CryENGINE 3 Game Development: Beginner's Guide
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
Free Chapter
Introducing the CryENGINE 3 Free SDK
Breaking Ground with Sandbox
Playable Levels in No Time
I'm a Scripter, Not a Coder
C++ and Compiling Your Own Game Code
User Interface and HUD Creation with Flash
Creating Assets for the CryENGINE 3
Creating Real-time Cutscenes and Cinematic Events
Immersion through Audio Design
Preparing to Share Your Content
Pop Quiz Answers
Index
Customer Reviews