www.it-ebooks.info UnrealScript Game Programming Cookbook Discover how you can augment your game development with the power of UnrealScript Dave Voyles BIRMINGHAM - MUMBAI www.it-ebooks.info UnrealScript Game Programming Cookbook Copyright © 2013 Packt Publishing All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews. Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book. Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information. First published: February 2013 Production Reference: 1080213 Published by Packt Publishing Ltd. Livery Place 35 Livery Street Birmingham B3 2PB, UK. ISBN 978-1-84969-556-5 www.packtpub.com Cover Image by Dave Voyles ([email protected]) www.it-ebooks.info Credits Author Project Coordinator Dave Voyles Arshad Sopariwala Reviewers Proofreader Kolby Brooks Maria Gould John P. Doran Indexer William Gaul Tejal R. Soni Dan Weiss Graphics Acquisition Editor Valentina D'silva Erol Staveley Aditi Gajjar Lead Technical Editor Production Coordinator Arun Nadar Nitesh Thakur Technical Editors Cover Work Pooja Prakashan Nitesh Thakur Veronica Fernandes www.it-ebooks.info About the Author Dave Voyles has worked as a coordinator for the last two Indie Games Uprisings on Xbox Live, an annual event organized to highlight the talented developers and their titles on Xbox Live Indie Games. Additionally, he has released a title of his own, Piz-ong on XBLIG, as well as projects using Unity and the Unreal Engine for game jams. He's proficient in C# and UnrealScript, and all facets of the Unreal Engine, as well as a number of 3D modeling suites, including 3DS Max and Maya. He has also worked as a technical reviewer on Unreal Development Kit Game Programming with UnrealScript: Beginner's Guide, Packt Publishing and Unreal Development Kit Beginner's Guide, Packt Publishing. Moreover, he works as managing editor at Armless Octopus, a site dedicated to cover Indie game development with an emphasis on XNA and XBLIG. You can find him on Twitter under the handle @DaveVoyles or at www.About.me/DaveVoyles. I'd like to thank my mother and father, for always supporting my gaming habit as a child, despite my poor taste in Sega CD era FMV games. www.it-ebooks.info About the Reviewers Kolby Brooks took a strong interest to programming at the young age of seven, getting his start by modifying games such as Unreal, Dirt Track Racing, and Half-Life. He now has over 14 years of growing experience in multiple game-related fields including, but not limited to, multiplayer anti-cheat solutions, game programming, and engine development. As a hobby, he develops and maintains multiple third-party solutions for games such as server tools, utilities, and modification frameworks. You can contact Kolby by e-mail at [email protected]. I would like to thank my family, especially my mother and father, for their continued support over the years. In addition, I would like to thank Jason Ismail and Draco Rat for being great friends and gaming buddies. John P. Doran is a technical game designer who has been creating games for over 10 years. He has worked on an assortment of games in student, mod, and professional projects independently as well as in teams having up to or over 70 members. He previously worked at LucasArts on Star Wars: 1313 as a game design intern, the only junior designer on a team of seniors. He later graduated from DigiPen Institute of Technology in Redmond, WA, with a Bachelor of Science in Game Design. He is currently a software engineer at DigiPen's Singapore campus while at the same time tutoring and assisting students with difficulties in Computer Science concepts, programming, linear algebra, game design, and advanced usage of UDK, Flash, Unity, and Actionscript in a development environment. www.it-ebooks.info He is the author of Mastering UDK Game Development Hotshot, Packt Publishing and is the co-author of UDK iOS Game Development Beginner's Guide, Packt Publishing. He can be found online at http://johnpdoran.com and can be contacted at john@ johnpdoran.com. Thanks so much to the author for allowing me to give him my thoughts while writing the book, I hope that they helped. I'd also like to thank my brother, Chris Doran, and my girlfriend Hannah Mai for being there for me whenever I needed them and being patient while I was working on this. I'd also like to thank Arun Nadar, Arshad Sopariwala, and all the lovely people at Packt for all of their support and knowhow! William Gaul is an aspiring game developer working primarily in the Unreal Development Kit (UDK). Since 2008, he has learned a wide range of skills in the industry, and maintains an active YouTube channel (http://www.youtube.com/user/willyg302) and blog (http://willyg302.wordpress.com/) dedicated to game development. His programming knowledge includes Java, C/C++, UnrealScript, BASIC, HTML/CSS, and LaTeX. He also specializes in a variety of media solutions, with experience in the Adobe Creative Suite, Blender, and FL Studio. Dan Weiss is currently a programmer working at Psyonix Studios in San Diego, CA. He is a 2010 graduate of DigiPen Institute of Technology, having worked on titles such as Attack of the 50ft Robot! during his time there. He has been working in the Unreal Engine since 2004, independently producing the mod Unreal Demolition for Unreal Tournament 2004 and Unreal Tournament 3. At Psyonix, he has been involved with Unreal Engine work on mobile devices, having released ARC Squadron for iOS devices. www.it-ebooks.info www.PacktPub.com Support files, eBooks, discount offers and more You might want to visit www.PacktPub.com for support files and downloads related to your book. Did you know that Packt offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at www.PacktPub.com and as a print book customer, you are entitled to a discount on the eBook copy. Get in touch with us at [email protected] for more details. At www.PacktPub.com, you can also read a collection of free technical articles, sign up for a range of free newsletters and receive exclusive discounts and offers on Packt books and eBooks. http://PacktLib.PacktPub.com Do you need instant solutions to your IT questions? PacktLib is Packt's online digital book library. Here, you can access, read and search across Packt's entire library of books. Why Subscribe? f Fully searchable across every book published by Packt f Copy and paste, print and bookmark content f On demand and accessible via web browser Free Access for Packt account holders If you have an account with Packt at www.PacktPub.com, you can use this to access PacktLib today and view nine entirely free books. Simply use your login credentials for immediate access. www.it-ebooks.info www.it-ebooks.info Table of Contents Preface 1 Chapter 1: Development Environments 7 Introduction 7 Using UnCodeX 8 Dungeon Defenders to save the day 12 Unreal Script IDE 14 nFringe 16 Unreal X-Editor 19 Editing runtime values with Remote Control 26 Chapter 2: Archetypes and Prefabs 33 Introduction 33 Constructing a leaking pipe prefab 34 Adding particles to our prefab 37 Adding audio effects to our prefab 39 Creating a PointLight archetype 40 Creating a subarchetype from an archetype 47 Chapter 3: Scripting a Camera System 53 Introduction 53 Configuring the engine and editor for a custom camera 55 Writing the TutorialCamera class 58 Camera properties and archetypes 63 Creating a first person camera 68 Creating a third person camera 72 Creating a side-scrolling camera 75 Creating a top-down camera 81 www.it-ebooks.info