Build a Game with UDK 1849695806, 9781849695800

Get started with the Unreal Development Kit and make your very first game! Overview Make games using the Unreal Developm

236 99 3MB

English Pages 156 Year 2013

Report DMCA / Copyright

DOWNLOAD PDF FILE

Recommend Papers

Build a Game with UDK
 1849695806, 9781849695800

  • 0 0 0
  • Like this paper and download? You can publish your own PDF file online for free in a few minutes! Sign Up
File loading please wait...
Citation preview

Build a Game with UDK

Get started with the Unreal Development Kit and make your very irst game!

Geoff Sholler

BIRMINGHAM - MUMBAI

Build a Game with UDK 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: August 2013

Production Reference: 1190813

Published by Packt Publishing Ltd. Livery Place 35 Livery Street Birmingham B3 2PB, UK. ISBN 978-1-84969-580-0 www.packtpub.com

Cover Image by Paul Steven ([email protected])

Credits Author Geoff Sholler Reviewers John Preston Doran

Project Coordinator Joel Goveya Proofreader Paul Hindle

Robert Hamilton Dan Weiss

Indexer Monica Ajmera Mehta

Acquisition Editor Erol Staveley

Production Coordinator Aditi Gajjar

Commissioning Editor Harsha Bharwani

Cover Work Aditi Gajjar

Technical Editors Dylan Fernandes Dipika Gaonkar Sonali S. Vernekar

About the Author Geoff Sholler has an interest in video games since he irst started playing them

around the age of ive. Many of his educational decisions were geared towards the end goal of getting into the business of making them, and as such, he attained a Bachelor's degree in Computer Science with a focus on Videogame and Graphics Programming from the University of Miami in 2008. After that, he went to the Florida Interactive Entertainment Academy (FIEA) at UCF and earned a Master's degree in the ield of Interactive Entertainment. While attending FIEA, he learned to use several professional-scale development toolsets, chief among them UDK. Upon graduating, he was hired by Trendy Entertainment, the makers of the hit game Dungeon Defenders, in a position which nobody can seem to ind a proper title for, but Asset Integration Specialist, Level Scripter, and Technical Designer tend to be the most common ways to which he is referred. They all sound better than ''the guy with a technical mindset who knows nearly all of the engine tools really well", which is possibly the most accurate description of his job. He has been working there since January 2012, which means he has been elbow deep in UDK nearly every day for the past two years, including school. I'd like to thank my parents for always believing in me, my friends for always being there with me, and Kristin, for brightening my life.

About the Reviewers John Preston Doran is a Technical Game Designer who has been creating games for over 10 years. He has worked on an assortment of games in teams of just himself to over 70 in student, mod, and professional projects. He previously worked at LucasArts on Star Wars 1313 as a Game Design Intern. He later graduated from DigiPen Institute of Technology in Redmond, WA, with a Bachelor of Science degree in Game Design. John is currently a Software Engineer at DigiPen's Singapore campus, while also tutoring and assisting students with dificulties in computer science concepts, programming, linear algebra, game design, and advanced usage of UDK, Flash, Unity, and ActionScript in a development environment.

Robert Hamilton is a composer and researcher actively engaged in the development of interactive musical systems. He is currently pursuing his PhD at Stanford University at the Center for Computer Research in Music and Acoustics. His research focuses on using immersive game-based environments as tools for musical collaboration, mixed reality performance, and the musical soniication of gamespace actors.

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 with 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.PacktPub.com Support iles, eBooks, discount offers and more

You might want to visit www.PacktPub.com for support iles and downloads related to your book. Did you know that Packt offers eBook versions of every book published, with PDF and ePub iles 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. TM

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? •

Fully searchable across every book published by Packt



Copy and paste, print and bookmark content



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.

Table of Contents Preface Chapter 1: Hello UDK!

1 5

Setup System requirements Download Installation Folders Shortcut Summary

6 6 7 8 8 9 10

Chapter 2: Moving Around in the Development Environment

11

Content Browser tabs Actor Classes Levels Scene Layers UI and Viewport layout

12 12 13 13 13 14

Viewport Camera Controls Hotkeys Viewport toolbar Editor toolbars

15 16 17 19

Summary

Chapter 3: Building the Geometry of the World CSG brushes and volumes Builder Brush Geometry Mode and the Pen tool Terrain tool Foliage tools Summary

19

21 23 23 24 26 30 31

Table of Contents

Chapter 4: Filling Out your World with Details Static meshes Architecture Decoration Particle effects Lighting Post processing Summary

33 33 33 36 37 42 44 45

Chapter 5: Kismet and Matinee

47

Introduction to Kismet Hello world Events Actions Conditions Variables Subsequences Matinee Director Summary

47 48 51 53 55 56 57 58 59 62

Chapter 6: AI Navigation, Pathing, and Enemy Setup Pylons and navigation meshes Path Nodes Enemies Spawning enemies Enemy movement Combat Gameplay Summary

63 63 67 69 69 72 74 75 82

Chapter 7: Physics

83

Fractured static meshes Basic physics actors Complex physics actors/ragdolls Other physics actors Physics Volume Force and Impulse actors Summary

84 88 90 92 93 94 95

[ ii ]

Table of Contents

Chapter 8: Sounds

97

Sound cues versus sound wave data Types of sound actors Using sound cues Ambient sound Ambient sound movable

98 98 99 99 99

Using sound wave data

100

Playing sounds in Kismet Playing sounds in Matinee Sound Cue Editor Summary

102 102 103 108

Ambient sound simple Ambient sound non loop Ambient sound non looping toggleable Ambient sound simple toggleable

101 101 101 101

Chapter 9: Materials

109

Importing a texture Material Editor Constants Coordinates Math Parameter Texture WorldPosOffset Decal materials Summary

110 110 114 114 114 115 115 115 116 116

Chapter 10: Characters and Animation Anim Set Editor Sockets and the Socket Manager Animation Notiies Anim Trees Animating placed skeletal meshes Animating in Matinee Summary

117 118 119 121 125 126 127 129

Appendix : Glossary of Terms Index

131 137

[ iii ]

Preface The Unreal Engine is used in many games out on the market. It's also used in other industries for things such as simulation. Regardless of the use, any product using the Unreal Engine will also use the Unreal Development Kit and the tools within it. This book will cover most of the tools included in the Unreal Development Kit.

What this book covers Chapter 1, Hello UDK!, gives you a brief rundown of what the book will cover and walks through the process of installing the Unreal Development Kit. Chapter 2, Moving Around in the Development Environment, goes over basic navigation within the editor. Chapter 3, Building the Geometry of the World, covers the usage of the tools utilized to create terrain and basic structures. Chapter 4, Fill out your World with Details, covers the usage of tools dealing with the use of things like meshes, visual effects, lighting, and post-processing to make the world feel more alive. Chapter 5, Kismet and Matinee, covers the use of Kismet, Unreal's visual level scripting tool, and Matinee, Unreal's cinematic and cut-scene creation tool. Chapter 6, AI Navigation, Pathing, and Enemy Setup, covers setting up the world to include some basic gameplay. Chapter 7, Physics, covers the tools available in UDK to create simple and complex physics objects. Chapter 8, Sounds, covers the creation and use of sounds in UDK. Chapter 9, Materials, covers the basics of using the Material Editor.

Preface

Chapter 10, Characters and Animation, covers the basics of setting up characters and using the animation editing tools. Chapter 11, Appendix/Glossary of Terms, is a simple reference of terms used throughout the book.

What you need for this book For this book, you need a PC with an Internet connection (to download the Unreal Development Kit) that meets the following requirements: •

Windows XP SP3 or Windows Vista



More than 2.0 GHz processor



2 GB system RAM



Graphics card with Shader Model 3.0 support



3 GB free hard drive space

The necessary software can be downloaded from www.unrealengine.com

Who this book is for This book is intended for people who are interested in learning how to make games utilizing the toolset contained within the Unreal Development Kit. Whether you've developed games before and are just looking to learn new tools or you're just looking to get started, this book will help.

Conventions In this book, you will ind a number of styles of text that distinguish between different kinds of information. Here are some examples of these styles, and an explanation of their meaning. Code words in text are shown as follows: "We can include other contexts through the use of the include directive".

[2]

Preface

New terms and important words are shown in bold. Words that you see on the screen, in menus or dialog boxes, for example, appear in the text like this: "Clicking on the Next button moves you to the next screen". Warnings or important notes appear in a box like this.

Tips and tricks appear like this.

Reader feedback Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or may have disliked. Reader feedback is important for us to develop titles that you really get the most out of. To send us general feedback, simply send an e-mail to [email protected], and mention the book title via the subject of your message. If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide on www.packtpub.com/authors.

Customer support Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.

Downloading the color images of this book We also provide you a PDF ile that has color images of the screenshots/diagrams used in this book. The color images will help you better understand the changes in the output.You can download this ile from http://www.packtpub.com/sites/ default/files/downloads/5800OT_Build_a_Game_with_UDK_Mini.pdf

[3]

Preface

Errata Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you ind a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you would report this to us. By doing so, you can save other readers from frustration, and help us improve subsequent versions of this book. If you ind any errata, please report them by visiting http://www.packtpub. com/submit-errata, selecting your book, clicking on the errata submission form link, and entering the details of your errata. Once your errata are veriied, your submission will be accepted and the errata will be uploaded on our website, or added to any list of existing errata, under the Errata section of that title. Any existing errata can be viewed by selecting your title from http://www.packtpub.com/support.

Piracy Piracy of copyright material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works, in any form, on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy. Please contact us at [email protected] with a link to the suspected pirated material. We appreciate your help in protecting our authors, and our ability to bring you valuable content.

Questions You can contact us at [email protected] if you are having a problem with any aspect of the book, and we will do our best to address it.

[4]

Hello UDK! I can tell you two things about yourself right now. First, you're interested in making video games. Second, you want to use the Unreal Development Kit to make them. Both of those are good, and I can tell you that you've come to the right place. This book will serve as a survey of all the tools present in the free-to-download Unreal Development Kit as well as a step-by-step manual on how to use these tools to construct a functionally complete game. The Unreal Development Kit is a great choice to learn how to make video games. If you develop and can show a mastery of this toolkit, it can easily get you a job in the industry if that's your goal. It can also be fun to work with as a hobby, or to create modiications (mods) to games that are made using it, if they allow you to do so. There are many reasons why UDK is a great choice for game development. First and foremost, if it's used non-commercially, it's free! There's no need to pay some ridiculous licensing fee or illegally download anything; there's a very robust toolset available online from Epic. Secondly, it's powerful. Unreal Engine is used in dozens of games, and if it was made in Unreal, then it is fairly likely that it used some version of UDK along the development process. Contained within this program are tools for dealing with physics, particle effects, in-game cut-scenes, level editing, sound effects, animations, and just about anything else you can think of that a video game would need. Third, it's accessible. Not a programmer? That's ine! It has a functioning code base as well as a visual scripting language that can do, albeit less eficiently, nearly anything you would need. Not an artist? That's ine too! UDK comes with a sizeable library of art assets, some of which are: •

Textures



Sounds



Characters with animations



Architectural pieces



Visual effects

Hello UDK!

And if it doesn't have exactly what you're looking for, there are tools that allow you to create variations on the included assets.

Setup The irst thing that we need to do is to download and install the editor. Now, UDK, being a professional level of game making software, may not run well on all machines. The system requirements and recommendations, which can also be found on Epic's website are as follows:

System requirements UDK is not the most hardware-intensive piece of software. But, being a professional level game development tool, it follows the same basic guidelines as any big budget PC game. It will run on moderately good systems, but the better the system, the better it will run and the more you'll be able to perform. •

Minimum PC requirements: °

° ° °

Windows XP SP3 (32-bit only) More than 2.0 GHz processor More than 2 GB RAM A graphics card with Shader Model 3.0 support [6]

Chapter 1



Recommended PC requirements: ° °

Windows 7 64-bit

°

More than 2.0 GHz multi-core processor

°

Nvidia 8000 series or higher graphics card

°

8 GB system RAM Plenty of hard drive space

Download So, we've made sure our computers can handle the software; now let's go ahead and download it. We'll navigate our web browser to http://www.unrealengine.com/ udk/ and click on the button on the page that says Downloads. From there, we'll not necessarily choose the most recent release, because Epic releases new versions pretty regularly, and I want to be certain that we're all working on the same version. So, below Download Latest Release, if it says July 2012 UDK Beta, then that's the one we want. If it doesn't, then we'll scroll down to where they keep a list of Previous Versions, and select the one that does say July 2012 UDK Beta.

[7]

Hello UDK!

Installation Now that we've got the installer downloaded, we'll need to run it and install UDK. The installation process is pretty straightforward. 1. The irst thing that pops up is the end user license agreement. Go ahead, and click on I Accept. 2. Next, we're prompted to select the folder where we wish to install it. If you don't have a speciic location to put it, go ahead and click on Accept, and it will begin the installation process. This will take several minutes. 3. After a few minutes, it will ask you if you wish to Install the Perforce Server and/or Install the Perforce Visual Client. This step is optional, but if you have Perforce and plan on utilizing it as revision control, then you might want to do this. For the purposes of following along in this book, we can skip it. So, we'll just click on Next and the installation will be completed. Perforce is a piece of software that is used for revision control. Revision control is a system to keep incremental track of a project and its iles. On a professional level, this software is used to make sure that everyone has the same up-to-date iles and that they don't accidentally overwrite iles they shouldn't.

Folders Now that we have UDK installed, let's look at the ile folder structure that it has set up for us. Navigate to where you installed UDK, and from there open the UDK folder. If you ind yourself programmatically inclined, you'll eventually ind your way into the Development folder. Within this folder is UDK's UnrealScript base. UnrealScript, as the name implies, is the scripting language developed by Unreal. It is used to create and control the behavior of almost anything in a game made in UDK. For the purposes of this book, we will not be venturing into UnrealScript. Unreal Engine, which powers UDK, is programmed primarily, if not exclusively in C++, which allows it to do some pretty powerful things by more directly communicating to some of the hardware's features. UnrealScript is a language exclusive to Unreal Engine that is more accessible, and gives users a simpler way to utilize a lot of Unreal Engine's more advanced features without having to dig as deeply. The native C++ runs faster than the UnrealScript, which in turn runs faster than the in-editor visual scripting language: Kismet.

[8]

Chapter 1

Next, we'll open up the UDKGame folder, and within that, the Content folder. This folder is important. It is where we'll be saving the map and package data and is where all of the characters, buildings, and other assets that UDK comes with are stored. Map is basically a level. Depending on the scope of your game project, the number of maps your game has will vary. You can even have a map that references other maps as sublevels. This functionality can be used to easily combine parts of a larger game world into chunks that are easier for the computer to deal with, or it can be used to keep certain aspects of a level separate, such as sound effects, visual effects, or level geometry. Separating these aspects in this fashion would allow for multiple people to be working on the same level simultaneously without any conlict. Package is basically a collection of actors, which is what UDK calls pretty much anything you can put into a level. You can store these actors directly in a map, but this is generally a bad idea, because actors stored in map packages can only be used in the map to which they belong. So instead, we'll keep anything we want to use in separate packages, so we can use them in other maps if we want to.

Shortcut Installing UDK should automatically create a shortcut in the start menu, but there's a possibility that it might not be created. If that's the case, or there's any dificulty getting into the editor, here's how to make a shortcut to the editor. Navigating back to UDK, we're now going into the Binaries folder, and then into the Win32 folder. If we scroll down, we'll see UDK.exe. We'll ind that if we double-click on and run that executable ile, it won't open any sort of development environment, but will instead open up what appears to be the main menu of a game of some sort. This is the correct behavior. To get to the editor, we'll have to make a special shortcut. To do this, right-click on UDK.exe and then click on Create Shortcut. This will create our shortcut. We can put this on our desktop so that we can easily access it without having to navigate to this folder. Now, we'll right-click on the shortcut and click on Properties. In the ield marked as Target, we'll see the complete ile path to UDK.exe. At the end of this, we'll add a space followed by editor and click on OK. Now, when we double-click on the shortcut, it will load up the editor and we can get started.

[9]

Hello UDK!

The page will look like the following screenshot:

Summary Now that we've downloaded UDK and gotten it ready to go, it's time to dive right in! The next chapter will introduce what we'll see upon opening UDK for the very irst time. For those unfamiliar with game editors, it may seem overwhelming, and that's ine. The next chapter illustrates what all the different windows and buttons are for, and will therefore take the edge off a little bit. So, without further ado, let's move on to the next chapter.

[ 10 ]

Moving Around in the Development Environment So, now that we have fully installed UDK, let's open it up. When you irst start up UDK, you'll be greeted by a somewhat overwhelming irst sight as shown in the following screenshot:

Moving Around in the Development Environment

The preceding screenshot is of the Content Browser. It will be one of our "best friends" as we proceed. This is where you can, as the name suggests, browse the content that is included with UDK. This includes the following: •

Static mesh: A game object that is not made to animate.



Skeletal mesh: A game object that is made to animate, and thus has a skeleton.



Particle system: A visual effect that can be made of several types of components.



SoundCue: A UDK sound object that takes a number of imported sound iles and mixes them to achieve speciic sound effects.

It also includes almost anything that you could look at or perceive in a video game world. And if there's something that isn't here, it can likely be found in one of the tabs at the top of the window.

Content Browser tabs

At the top of the same window, we'll ind a number of tabs. These tabs will give us access to tools and systems that are both important and useful in the process of making a game using UDK.

Actor Classes The Actor Classes tab will show us a list of all the objects we can place in the level. With the right settings, it can show us pretty much anything in UDK that has an associated UnrealScript class. This will be important when we need to make archetypes.

[ 12 ]

Chapter 2

Class: For those unfamiliar with programming terminology, a class is basically something which can have instances of itself made that are individual, but share common traits. In UDK, anything that is an actor in a level has properties dictated by a class in the UnrealScript codebase. Archetype: Archetype is a useful tool in UDK. Basically, it allows you to take almost any class and bring it into the Content Browser, where you can adjust a number of its settings to suit your needs without having to go into the code, potentially ill-effects from going into the code.

Levels The Levels tab will show us a list of all the sublevels that are referenced to by our map. It will allow us to switch between which level we are working in and/or toggle them to be hidden or not. Sublevels are generally used in two different ways. First, they can be used to set up level streaming in order to allow for the creation of large open world games. Secondly, if working with a team, they can be utilized to handle different parts of a smaller play space simultaneously. For example, if one person were to work on the visual components of the level while another worked on sounds, then they could do so using the sublevel system.

Scene The Scene tab basically gives us a list of all the actors in our map along with access to their properties. In my personal experience, we won't end up using this particular tab very often. Most of the important functionalities, if not all, are present in other places.

Layers The Layers tab, called Groups in earlier builds of UDK, basically shows us actors in our map for which we've put something in the Layer property to group it with other actors. This method of grouping can be used to categorize actors in our maps by applying whatever organizational label we want. For example, if our map has dozens of static meshes, and we want to be able to select all the meshes that are stairs at the same time, we could. To accomplish this, as we place one of these stair static meshes we would go into its Properties and set its Layer Property to say stairs. Then, when we looked in the Layers tab, we would see a layer titled stairs, and when we click on it, it would list all of the actors we had labeled as stairs.

[ 13 ]

Moving Around in the Development Environment

UI and Viewport layout Now that we've gone over the Content Browser, we can close that and take a look at the UDK Viewport. This shows us our level in a very tactile way, and this is where we'll spend a great deal of our time. In this window, we'll place all the pieces that make up our visible and audible game world as well as gameplay elements that help us control the behind the scenes clockwork of our game.

UDK by default furnishes each new map with some basic static meshes, a skybox, and some lighting and post-processing presets for a speciic time of the day. We can choose to have UDK start us with nothing, but for the sake of learning the tool, it can be helpful to have examples of things set up and in place for us. The four important things to learn with regards to navigating this environment are: •

Viewport Camera Controls



Hotkeys



Viewport toolbar: functions and layout



Editor toolbar: functions and layout

[ 14 ]

Chapter 2

A skybox or skydome is a static mesh set up so that the interior part displays an image of a sky. Lighting is pretty straightforward, so far as it refers to the way the level is lit. This includes placement and coniguration of different types of lights so everything looks exactly how it should. Post processing refers to visual effects that apply as if there was some sort of ilter put in front of the camera. Effects such as ilm grain, saturation adjustments, and more are possible within UDK's post-processing functionality.

Viewport Camera Controls The default viewport of UDK is what you see in front of you. It is called the perspective view, which means that it shows you your game world with all the three dimensions. It also allows you to view your map from locked rotation top, front, and/or side views, which shows you a ixed orientation of two of the three dimensions. The top view uses just the X and Y dimensions, the front view uses only the Y and Z dimensions, and the side view uses only the X and Z dimensions. It is worth noting that the Z axis is the one that is used for elevation. These views will prove useful when we are trying to align actors in our level just the way we want them. If we are ever unsure which view we are looking at, we can see a letter representing our view (P, T, F, or S representing the perspective, top, front, and side iews respectively) in the upper-left corner of the Viewport window. Clicking on this letter will cycle through the different views. We can also view multiple views using a split Viewport by clicking on the icon circled in red in the preceding image. Moving the camera in either the top, front, or side views is a matter of panning and zooming. In these three views, clicking and dragging with the left mouse button or the right mouse button will pan the camera. Clicking and dragging with both mouse buttons will zoom out by dragging the mouse upwards, or zoom in by dragging the mouse downwards. Alternatively, if your mouse has a scroll wheel, you can use this to zoom. UDK, by default, links its orthographic viewport's movements. This means that if you move the camera on the X axis in the top view, it will also move it along the X axis in the side view. If you ind this distracting or unwanted and you wish to disable it, click on Preferences at the top of the window and then uncheck the Link Orthographic Viewport Movement option.

[ 15 ]

Moving Around in the Development Environment

Moving the camera in the perspective view is a little bit different. Clicking and dragging left or right with the left mouse button will rotate the camera counterclockwise or clockwise, respectively. Clicking or dragging the left mouse button up or down moves the camera forward or backward in the XY plane based on what direction the camera is facing. Clicking and dragging with the right mouse button allows us to freely look around. Using the keys W, A, S, and D (or arrow keys if they are more comfortable) moves the camera forward, backward, left, and right while keeping its viewing angle locked. These controls can actually be used in combination with the right mouse button's free look controls previously mentioned that allow us to basically ly around our level using a control scheme not completely different from if we were playing a game. For added control while lying around the map, we can adjust our movement speed by using the scroll wheel. I personally highly recommend this system for getting around in the perspective view because it utilizes a control scheme that should be instantly familiar to anyone who has previously used a spectator mode in an FPS.

Hotkeys UDK has a large amount of hotkeys. That is to say that it has many button combinations available to call speciic, commonly-used tasks. As we progress through this book, I will bring up any hotkeys that are relevant to what we're doing. In terms of basic editor navigation, there are only a few: •

Ctrl + B will locate the selected actor in the Content Browser. This can be of great use if we're trying to change a setting globally for every instance of that actor in the map.



Ctrl + S will not save, but will instead create a subtractive brush.



Alt + W will toggle the visibility of static meshes.



Alt + T will toggle the visibility of Terrain.



Alt + Q will toggle the visibility of BSP.



Home will center the camera on whatever is selected in the map.



O will toggle the visibility of Volumes.



B will toggle the visibility of the building brush.



Spacebar will toggle between the Translation, Rotation, and Scale widgets on whatever is selected.

[ 16 ]

Chapter 2

Translation and Rotation are both handled on a per axis basis by the default. The Scale widget, however, defaults to uniform scaling. If we need to scale something in one direction, we need to click on the icon circled in blue in the image of the Viewport.

Viewport toolbar The Viewport toolbar is located to the left of the Viewport. It contains ive different sections that primarily focus on placement and adjustment of the different types of volumes as follows:



Modes allows us to switch between different modes. The most important modes are the default camera mode, which allows us to do most of what we need to in terms of looking around our level and placing/moving, things and the geometry mode, which allows us to have very ine control over shaping any volumes in our maps.

[ 17 ]

Moving Around in the Development Environment



Brushes gives us some preset shapes to use to make volumes. Left-clicking on any of these shapes makes the brush into that shape using default settings. Right-clicking opens up the settings available for that brush shape. In the Viewport, the brush is represented by a red wireframe shape.



CSG stands for Constructive Solid Geometry, and it is a series of functions that can be used in conjunction with the brushes to quickly create a playable space.



Volumes lets us build one of UDK's various volume types in the shape and location of our brush in the world.



Select gives us some options for hiding actors based on which actors we have selected. It can be helpful if we're having trouble selecting certain objects because of other objects being in the way.



Go To offers the option to move the camera to whichever actor we have selected, or move it to wherever the builder brush is currently located. That irst function is covered by the use of the Home hotkey. The second function, however, is extremely useful.

[ 18 ]

Chapter 2

Editor toolbars

This pair of toolbars offers us some standard functions such as Save or Load, but they also give us access to many of the special tools UDK has to offer such as Kismet or Matinee. Also on these toolbars are options for compiling parts of the map. Namely, the options to Build Geometry, Build Lighting, and Build Paths are on the upper toolbar. The lower toolbar controls viewing options of the Viewport that it is attached to. There are three very important entries on this toolbar. The ability to put the Viewport into the wireframe mode can be helpful when dealing with volumes. Game View gives us an accurate view of how our level will look, disregarding things that we have hidden or things that wouldn't be visible in the game, such as volumes. Finally, Realtime View will show us things in our level that move as a part of what they are. For example, if we have a particle system and we want to see how it looks in the level, we would turn this option on and it would do whatever we've made it to do. This doesn't work for things like moving platforms or anything else that will be controlled by UnrealScript, Kismet, or Matinee.

Summary Now that we have a basic understanding of how to maneuver around the editor and the location of some of the more important buttons, we can actually start making a game. You might be curious to know about all those other buttons that I didn't take the time to go over. Many of them will be covered later on in the book. But, in general, I'd say run with that curiosity. There will be aspects of UDK that this book doesn't have time to cover at length, but that does not mean that they aren't worth exploring. So, don't feel that you have to follow the examples in this book to the letter. It is simply here as a guide.

[ 19 ]

Building the Geometry of the World In this chapter, we're going to cover how to basically build a world for our game to live in. It won't be a inal, fully leshed out world, but we'll set up the basic shapes and spaces using the different tools that UDK offers which are as follows: •

First, we'll cover how to quickly block out a space using the CSG Builder Brush to layout CSG and volumes.



Then, we'll take a look at the Terrain Editor. We won't go over the Landscape tool, because although it is a newer and more powerful version of the Terrain Editor, it requires a much more in-depth look than we have time for.



After that, we'll take a look at the Foliage tool to lesh out any outdoor areas that we have quickly.

So, now we're actually going to start building our game world. For the purpose of this book, I'm going to be using a game world with both a building interior and an exterior area so that I can demonstrate the different tools. You can design your game world in a similar fashion, or you can make it completely interior or completely exterior. That's the point! With UDK's tools, in terms of level design, we can make whatever we want, and we will only be limited by the art assets at our disposal, which, thanks to UDK, aren't even that limiting. So, let's go ahead and click on File and then New Level.

Building the Geometry of the World

We'll be prompted to select a map template as shown in the following screenshot:

For the purpose of this book, I would suggest that we select one of the lighting options, but whichever one is a matter of preference. I'll be working on the Night Lighting template. Once you get more familiar with the editor, you might prefer to start with a Blank Map template, but for this book, we should start with one of the templates.

[ 22 ]

Chapter 3

CSG brushes and volumes The irst method of world construction that we're going to learn about is the CSG Builder Brush, which is used to deine areas to create quick and easy geometry. It's incredibly useful for blocking out large lat areas quickly. In this example, we're going to use it for two purposes. First, we're going to get an idea of how large we want our overall playable area to be. This will mean, more or less, that we're going to just lay down a big lat area to run around in and get some sort of sense of size. Part of this area, in this example, will be a building interior, and part of it will be a landscaped exterior, but for right now, we're just getting an idea of the size. When thinking about the level size and layout, we need to think about what sort of game we're making and what we want to include. For example, if we want to make a game for Deathmatch, it would be a completely different design than a map for a linear action adventure game. For this book, the plan is to create a quick and dirty survival-style game which will have lots of action, lots of explosions, and lots of ways to show off UDK's tools. With this in mind, we've got a few options. If we want to make a smaller level game, it will be fairly easy to condense the action and keep the tempo up. However, if we want to make a bigger level game, it will become more dificult to keep a constant heightened level of danger. A larger level, however, could make the game more fun. It's really just a matter of preference.

Builder Brush

The irst tool we're going to use is the Builder Brush.

[ 23 ]

Building the Geometry of the World

This tool has many distinct uses, as it can be shaped and formed the way we want and then can be used to place many different types of volumes. For the purpose of this chapter, we will mostly be concerned with learning how to shape the brush in order to make basic level geometry such as buildings or stairs. To make a basic shape, UDK gives us many preset options. If we look at the preceding image, we'll see buttons for cubes, cones, curved stairs, cylinders, straight stairs, sheets, spiral stairs, spheres, and cards. If we left-click on any of these, it makes a brush in the given shape based on the current settings. If we right-click on these buttons, it will give us an options menu for the shape in question.

Geometry Mode and the Pen tool While these shapes are great places to start for forming brushes, there are two other tools that are even more important: the Geometry Mode tool and, within that, the Pen tool.

Geometry Mode is a very useful tool for shaping volumes, as it allows us to grab vertices, faces, and edges to control our brush shape more effectively. It also has some useful features such as Split and Extrude, which allow us to build and shape our brush almost as if we were working in a 3D modeling software. For what we're covering in this chapter though, Geometry Mode is mostly just useful for lining up our CSG volumes so that there aren't any gaps between them. [ 24 ]

Chapter 3

In the list of Geometry Mode tools, we'll ind the Pen tool. This function allows you to draw, point-by-point, a 2D shape for your brush. When we complete the shape, it extends it into a 3D shape. Because it works in a 2D manner, it can only be used in one of the 2D views. Therefore, it won't work in the perspective view. It is very handy for when we'll be placing volumes and could potentially be handy for laying out CSG. With a combination of these Builder-Brush-related tools, we're pretty well-equipped to make some basic structures. To do this, we'll be making use of the CSG tools.

These are four simple tools that allow us to quickly block out a rough draft, so to speak, of our level. If we click on the Add button, it will make a solid object in the shape of our brush. If we click on the Subtract button, it will make a negative space in the shape of our brush. That is to say, if you put it in the middle of a volume on which you used the Add button, it will cut a hole in it. The other two buttons, Intersect and Deintersect, will basically take our brush and either remove everything that isn't intersecting another CSG volume or remove everything. For example, if we want to make a simple building: 1. We'd start by right-clicking on the cube brush in the Brushes portion of the toolbar. This will open up the Brush Builder window giving us the option to set the size of it in all three dimensions as well as whether or not it should be hollow, and if so, how thick the walls should be. For this example, we want the cube we're making to be hollow, and the wall thickness is ine at the default of 16. 2. Next, we'll use the Add button to make a hollow cube matching the dimensions of the brush we just created. 3. We can then use a mix of Brush Builder and Geometry Mode to shape windows and doors one at a time. 4. When we've got each door and window placed exactly where we want them and have made sure the volume goes all the way through the wall, we'll use the Subtract tool to cut a hole.

[ 25 ]

Building the Geometry of the World

5. Then, we could add a walkway and some stairs using the various preset brushes. At the end of the day, we have a pretty simple building. It doesn't quite look like a building because it's got the default checkerboard texture on it, but that's ine for now.

If ever we need to move something we have constructed with BSP, then we'll have to move the volume. To clearly see the volume in question, we need to click on the Brush Wireframe button at the top of our Viewport or hit Alt + 1. Once we think we've got it where we want it, we'll also have to hit the Build Geometry button in the upper toolbar.

Terrain tool Now that we have a rough shape for our level, we're going to make the outdoor portion using the Terrain Editor. We'll be using this tool instead of the Landscape tool because the Landscape tool is much more complicated. The two share a lot of basic functionality, so it is good to learn the Terrain tool irst, in my opinion. The Terrain Editor gives you the ability to quickly create mountains, valleys, and many different landscapes with a variety of effects and materials. The end result can be rather impressive, especially considering how quickly this work can be done. To start working with the Terrain Editor, we have to irst add some terrain to our level. To do this, click on Tools and then click on New Terrain. It will pop up with a little menu asking for a location to place our new terrain as well as some parameters called Patches. Patches basically control how big your terrain is. So, really it's a matter of how big your level is going to be. When we've tried out a few numbers and found the right set, we'll click on Next and it will build us a perfectly lat terrain actor. Now we'll get to work shaping our surroundings. [ 26 ]

Chapter 3

The primary tools we'll be using are the Paint tool, Smooth tool, Flatten tool, and Noise tool. The Paint tool allows us to raise or lower the area under our brush by holding Ctrl with a left mouse click or Ctrl with a right-click, respectively. If we ind our terrain too jagged, we can switch over and use the Smooth tool with the same Ctrl and left-click system. If we want to make a plateau, or a mesa, or level out some area for a building, then we'll switch over to the Flatten tool and, again, use Ctrl with a left-click. The trick to using the Flatten tool is that it will latten whatever you drag the mouse over based on the height of where the mouse started. We would do well to keep that in mind. If we know we want some height variation, but don't feel the need to do each little task by hand, the Noise tool will add some random height variation with, you guessed it, Ctrl with a left-click. Also, if at any point we ind that we need or want more or less detail in our terrain, we can increase or decrease Tessellation by clicking the appropriately labeled buttons in the Terrain Editor window.

[ 27 ]

Building the Geometry of the World

This will add or remove vertices, and either way, UDK will pop up asking if we're sure.

Now that we have all of our height variation laid out, we're going to replace that nasty checkerboard texture with something that is a little bit more earthy. You may be asking yourself why we're dealing with this checkerboard when we left the one on the building, and there are two reasons. First, adding materials to CSG is pretty much the same as adding them to anything else, whereas the process of making Terrain look like the actual terrain is part of the tool. Second, although it's really a matter of preference, CSG is commonly used as sort of a rough draft on how you want things to look. This is especially true if you have a team that includes artists who can make better looking assets than those that can be made by the Builder Brush. Adding materials to Terrain is a pretty painless and actually fun process: 1. What we'll need to do irst is right-click in the layer list in Terrain Editor and then click on New Terrain Setup Layer. This will pop up with the standard UDK widget for making a new object. It will automatically have your map package illed in, so we just have to give the layer a name. 2. If we're going to start with a layer of dirt, gravel, sand, rock, or whatever else, we should name it something along the lines of Terrain_Layer_Dirt. This will pop up with your new layer in the Terrain Editor window. 3. From there, we'll need to actually add a material that looks like whatever substance we want to paint with. So, we'll right-click again on the new layer we just created and select New Terrain Material. [ 28 ]

Chapter 3

4. Again, we'll get that little pop-up widget, and this time we'll want to name our material something along the lines of Terrain_Material_Dirt. This will pop up with a new Terrain Material in the Content Browser. 5. We're going to right-click on that and click on Properties.... 6. Then, we'll look in the Content Browser for a material that its what our layer is meant to be. Generally, if we search for dirt, sand, or rock, UDK will have one or two options. When we ind a material that we like, we will plug it into the ield labeled Material by having it selected in the Content Browser and clicking on the little green arrow next to the Material property. With this irst layer, it will automatically apply the material to the entire terrain. Subsequent layers will, initially, make no noticeable mark. But, if we select that layer in Terrain Editor, select the Paint tool, and then press Ctrl along with a left mouse click and drag around our terrain, we'll see whatever material we have in the selected layer being painted onto our terrain. 7. From here, we can add more layers as needed to give our terrain a nice sort of gradual low. We could have a grassy valley leading into a rocky mountain crisscrossed by dirt paths if we wanted, or the sandy desert of a beach. Even with UDK's prepackaged materials, there are a good number of options for us to work with.

[ 29 ]

Building the Geometry of the World

Foliage tools Now that we have the basic indoor and outdoor portions of our level shelled out, we'll add some details. First of all, we'll add some foliage to our outdoor section using the Foliage tool. This tool allows us to basically paint plant life onto our map rather than having to meticulously place each tree. It allows for faster placement of these types of assets with no real loss of visual form.

This tool is actually pretty straightforward. We'll go into the Content Browser and ind some static meshes that we like (searching for "tree" in the Content Browser will return some good options), and then we'll drag those into the Meshes area in the tool widget. From there, we'll use the Paint tool in the same way as we have been using the Paint tool within the Terrain Editor window and press Ctrl along with a left mouse click to add the static meshes we selected with the settings that we've applied for things like Brush Density.

[ 30 ]

Chapter 3

If at any point we ind that the editor is running really slowly, it may be a matter of rebuilding the lighting by clicking on the Rebuild Lighting button on the top toolbar. For the work in progress lighting builds, just use the settings of Preview Lighting and uncheck the Use Lightmass box.

Now that we have some terrain with a basic structure and some trees, it's sort of starting to look like a level. At this point, we should probably hop into our level by clicking on the Play in Editor button on the top toolbar. While we run around and admire our work, it's a good idea to look for pits that we can get stuck in or ramps that are too steep to walk up and go and ix them.

Summary So, now we've got a basic understanding of the various tools UDK has to offer to block out a rough draft of a level, we have to move on and start leshing out the details. In the next chapter, we'll learn about adding details to our level. This will include learning about the different types of volumes and how to place static meshes. It will also include some basic design techniques to help as we try to give our level some personality. On more interesting notes, it will go over visual effects in UDK and how to edit them using the Cascade tool. It will also include how to set up lighting above and beyond the dominant directional light that the preset templates include. Finally, it will give a brief overview of the post-processing system, which can really give our game some life.

[ 31 ]

Filling Out your World with Details Now that we've got a rough idea of our level layout, let's add some details. In this chapter, we will cover the following topics: •

Static meshes



Particle effects



Lighting



Post processing

Each of these features of UDK has a role to play in making our level feel more like a unique world.

Static meshes Static meshes in UDK serve a variety of purposes. They can be used as they are for replacing CSG or to add decoration or become set pieces. They can also be brought in as InterpActors to be used when we want them to move. We're now going to go over the basics of setting up our static meshes.

Architecture The irst thing we're going to do is replace our CSG building with one made of static meshes. The main reason for this is that it will be easier to move these areas around without having to constantly rebuild geometry. So, what we need to do irst is look in the Content Browser to ind a good static mesh to make the walls out of and just drag-and-drop it into the map. This is one of the easier ways to bring static meshes into the game level.

Filling Out your World with Details

Now ideally, any buildings we've roughly laid out using CSG are easily converted into static meshes. In our example, we have a very square building with some stairs, doors, and windows. Because of these doors and windows, it will be better to use whatever wall we choose and just tile it using our 2D viewport views and also use the BSP volumes as guidelines in Brush Wireframe View. While we're just getting the basic walls into place, we don't need to worry about the windows and doors. We'll come back to those later.

Rather than copying and pasting these wall segments one at a time, we can simply select one and then Alt + left-click and drag to duplicate it. Once we have a row, we can select all of them and Alt + left-click and drag them until we have a full wall. We can then Alt + left-click and drag and then use the rotation functions to set up our other three walls quickly.

When using a 2D viewport view to set the location of objects, the arrow keys can be used to adjust the location, rotation, and/or scale depending on which of the three modes the Mode Widget is currently. [ 34 ]

Chapter 4

At the bottom of the screen, we'll ind some icons and numbers next to checkboxes. These control snap-to-grid functions from left to right, location, rotation, and scale. The checkboxes turn the grid-snapping on and off, while clicking on the arrows opens up a miniature drop-down menu that can control the amount that each will increment in power of two increments. This can be especially useful when using 2D viewport views to align things, as it allows iner placement, particularly with the location settings.

Now that we have our walls in place, let's go ahead and add our doors and windows. The way to do this is similar to when we set up our rough building outline with BSP; we'll take out the sections of wall we don't need. This is why it's better, in this case, to have made our walls out of many tiled pieces as opposed to having scaled up one static mesh. We can toggle static meshes being visible in our viewport by using Alt + W. This will let us see roughly whether our windows and doors are in our shell and approximately which meshes we'll need to delete. Don't worry if the doorways and windows don't match up with the BSP shell's doorways and windows, as our next step is to select the BSP additive volume of our shell and the BSP subtractive volume, which included our doors and windows and delete them. It is possible, and in fact handy, to save a CSG brush as a static mesh. If we right-click on the volume and select Convert and then Convert to Static Mesh, it will pop up with the same UDK widget we've seen before. Select a package, name your new static mesh, and click on OK. Voila, a new static mesh that you created.

In our example, we won't completely remove the BSP as there are some areas where it's unnecessary to have anything beyond the simple geometric shape provided by it. Places where the player will never be able to get a good look, such as ceilings, are great places to just put a BSP volume. Stairways can also be a good place for them as well. Also if there is any locations where we've created sort of odd shapes, it would be time consuming and/or dificult to recreate those shapes with the stock static meshes available to us. So it would be best to leave this area as BSP.

[ 35 ]

Filling Out your World with Details

Using these suggestions and our judgment, let's go ahead and lesh out the remaining interior architecture of our building.

Decoration Another great use of static meshes is to help us make our level feel like it's an actual world. What this means is taking a step back and thinking about what sort of place your level is and, likewise, what should be in it. Do animals or people live nearby? Maybe it's an old abandoned building that hasn't been in use. Maybe it's a space station. Whatever it is, we should try to think of it as we would a character. If we were thinking up how a character should look, and he was some sort of crime ighting vigilante, he'd very likely have some sort of tool or utility belt. These are some of the details a good level needs to feel right about. This maybe is one of the most important steps in having a good looking game, and it is one of the easiest to overlook. Placing decorations is the same process as with any other static mesh, so we won't go into great details as to how to do this. But it seemed necessary to put an emphasis on nonetheless.

[ 36 ]

Chapter 4

See what a difference that makes? This isn't the most decorated or pretty level in the world, but even this little bit of detail adds to the feel of it.

Particle effects Particle effects are one of the main forms of visual effects in games. If we see a ire, an explosion, bullet trails, muzzle lashes, or nearly any other special effect, it is likely done using particle systems. Basically, a particle can be just about anything, usually deined by a material, and then the behavior of these particles in terms of numbers and motion are deined by us. Levels of randomness are generally included for things such as ires or explosions, but other things like the previously mentioned bullet trails are fairly strictly deined. How are these special effects created? Well, that would be just one more reason why UDK is a great game making toolset. It comes with Epic's own tool for making these wonderful little things. The tool is called Cascade, and we're going to take a quick look at it. To access Cascade, we're going to go into our Content Browser and we can either double-click on an existing particle system or, if we want to just start from scratch, right-click on some empty space and select New ParticleSystem. The ever present UDK new item widget will pop up and ask for the package and name of this new particle system. For this phase of the tutorial, we're going to be making an effect for those little dust particles you see loating in sunbeams. It's a simple effect to make, so it will serve as a good introduction to Cascade. With that in mind, we should probably name our new particle system as Dust, or something along those lines.

[ 37 ]

Filling Out your World with Details

Clicking on OK will create our new particle system and drop us into Cascade with the default template as in the following screenshot:

What we're looking at can be a little overwhelming if we don't know what we're doing. So let's walk through this step-by-step and get acquainted with Cascade. First thing's irst: we need to get rid of those blue, red, and green plus signs. So, let's replace it with a good dust material. Rather than search looking for a proper dust material, let's just use the material CTF_Flag_IronGuard.Materials.M_CTF_Flag_ IronGuard_Flare. It is one of UDK's default materials and is a simple circular corona. To insert this in place of the current cross material, we'll click on the Required tab under the Particle Emitter and then where it says material, locate the mentioned material in the Content Browser and copy and paste it into that ield. Now we'll see a bunch of white dots loating generally upward. Obviously we're not done, because this doesn't look anything like dust in the light. Going down the list of tabs, we'll click on Spawn next. The only number we're concerned with here is the Constant number which can be found under Rate, then Distribution. By default it is set to 20, but we'll certainly need more dust than that. Depending on the size of your rooms or building, we could go as high as 500, but for now let's just bump it to 100 and see how it goes. It certainly makes a notable difference as in the following screenshot:

[ 38 ]

Chapter 4

Clicking on the Lifetime tab and then Distribution will present us with two values: Min and Max. In our case these two values set a minimum and maximum range for how much time in seconds any given particle will last. We'll encounter these sorts of distributions a lot in UDK to help us constrain things that need to be somewhat random. Let's set the Min to around 4 and the Max to something high like 15. If we zoom out by right-clicking and dragging it in the Preview window, we'll see that our little white dots are lying much higher thanks to the extended time we gave them. Moving on to the Initial Size tab, we'll expand the Start Size, Distribution, Max, and Min categories. This is a similar distribution, but since we're operating in 3D space, we have vectors to handle things like size, location, or velocity. Since we're making dust particles, they should be pretty small. So let's set the Max somewhere around 3 in the X, Y, and Z components, and the Min to around 1. These tiny little dots sure look a lot more like dust particles, don't they? But they're still moving way too fast.

[ 39 ]

Filling Out your World with Details

That brings us to the Initial Velocity tab, where we'll expand the Start Velocity, Distribution, Max, and Min categories. Similar to the size, we have vector values for the velocity. Now when we think of dust in light, it tends to drift very slowly, and the only thing we can say for it in general is it will loat down. So, we want to put the Max at something like 1.5 for the X and Y parameters, but -1 for Z because that way the dust will always loat down. The Min values should be the opposites for X and Y, so -1.5. For the Z parameter, we'll put it at -2. Now we can really see somewhat dust like behavior. The only problem is it's all coming from one point. It almost looks more like gently falling snow. We could easily adapt this particle system to actually be gently falling snow.

Looking at the two tabs left on the list, there isn't anything that would indicate control over the location the particles are coming from. So we'll have to add one. To add a tab to the Particle Emitter, we'll right-click somewhere in the empty space below Color Over Life and then click on Location, and then Initial Location. We'll see that in Initial Location, we're presented with more vectors values. This is another set of values that will depend on the size of the area we want to put the dust in. Basically, if we have a shack that's 256 units large, and we want dust all over the place, we'll make the Min values 0, 0, 0 and the Max values 256, 256, and 256. We could also make them negative and positive, so as long as the difference accurately represents the size of our room. In this case, let's go with negative and positive 256 in the Min and Max X, Y, and Z values, respectively. This will give us a cube with a side of 512 where the particles will spawn. Since our level, depending on the time of day we selected, will possibly have a light color that will match our particle system. So, now we're going to click on Color Over Life. The default distribution for this tab is a curve, which can be very daunting to look at for the unfamiliar. So, to make our lives easier, let's click on the little blue downward arrow to the right of the Distribution ield and select Distribution Vector Uniform. When dealing with colors as vectors in UDK, the X, Y, Z parameters correspond directly to red, green, and blue, respectively. On the usual 0 to 255 scale, 0 is 0 and 1 is 255. Going over 1 can add to over saturation or color emission, which can be useful.

To make sure our particle system matches in color to our level, we should hop into our level and ind the Dominant Directional Light. If it's hiding from us we can use the Find Actors function noted in the top toolbar by an icon of a pair of binoculars. [ 40 ]

Chapter 4

Opening this up, we can search for light and it should give us the light we're looking for and the Lightmass Importance Volume. Select the light and click on Properties. If we go to Light, then Light Component, then Light Component again, we will see Light Color. Click on this and it will give you RGB values for the light's color. We're going to have to do a little math and divide these numbers by 255 to get the vector values. What we'll do with these is multiply them by about 10 and plug them into the max values. Then put about half of that into the min values. This will make our particle system stand out, as it will actually be emitting it's own light, imitating the way dust relects the light that hits it. Now we have our particle system, and we can place it in the level by either dragging it in from the Content Browser or, since sometimes UDK can be inicky and not let us do that, by right-clicking in our level and selecting Add Emitter: followed by the name of our emitter.

With tools as powerful and complex as UDK's Cascade tool, it would take too long for this book to go over every little detail. I cannot stress enough the importance of just trying out the different things and seeing what they do. That's how I learned probably about 80 percent of what I know about UDK. I read through some basic tutorials of the tools to get a handle on where things are, and then I just had fun with my new toy. [ 41 ]

Filling Out your World with Details

Lighting There are a number of different kinds of lights in UDK. All of them with their own properties and uses are listed as follows: •

Directional Lights: These are generally used in their Dominant Directional Light form to simulate the Sun or the Moon. They act as though there's just some light, somewhere off in the distance that just affects everything in its range. Generally, since these lights tend to represent things like the Sun, this behavior is what we're looking for. Our level template came with one of these lights.



Spot Light: This is exactly what it sounds like. It is a much more focused directional light emanating from a set location for use of things such as, well, spot lights or lashlights, and those sorts of things.



Point Light: It is sort of a standard light, particularly for indoor scenes. It is a light that just emanates in all directions around its location. It is used for lamps, torches, and other forms of general lighting. If we hold down L and left-click on our map, it will place a point light where we have clicked.

Now we both know that there's more to these lights than just drag-and-drop and hope for the best. In each sort of light, there's a slew of properties we can change by selecting the light and hitting F4 to bring up the properties of the selected light. We have control over the color, brightness, direction, radius, and settings that provide things such as shadows and light shafts. You can get some stunning light effects from playing around with these settings, so go nuts. We just need to remember to rebuild lighting when we're done or else we won't see any difference. Speaking of building lighting, you may have noticed that there's a checkbox that is always checked by default and is present next to Use Lightmass. We haven't covered lightmass yet, so all we know for certain is if we forget to uncheck that, it makes light builds take longer. Well there's a very good reason for that. It's the more powerful way of building lighting, and will make your lighting look more realistic. So, maybe we won't use it on our work in progress maps, but we should deinitely remember to use it when we're done or think we're done. To make sure it doesn't go crazy trying to use lightmass on everything (including that enormous sky sphere we have), we need to place a Lightmass Importance Volume. Fortunately, the template we selected came with one, so all we need to do is resize it using Geometry Mode or the Non-Uniform Scaling tool so that it encompasses the playable area in our map.

[ 42 ]

Chapter 4

[ 43 ]

Filling Out your World with Details

Lighting is one of the prime examples of the "just play around with it" philosophy. As long as we know which types of lights to use in which situations, and that's been covered already, then it's really a matter of playing around with the settings until we like the way things look. Once we get lighting how we want it, or how we can't seem to make it any better, if we still don't like the way things look, well then we move on to post processing.

Post processing Post processing is, basically, taking all the rendered pixels and applying some extra effects to them right before they go to the screen. It can be used globally to adjust the overall feel of a map, to give a special rendering effect, or they can be constrained to given areas to make certain rooms feel different. To globally apply a post processing effect, we can either use a post processing chain and apply it to the world properties by clicking on View and then World Properties and setting a Post Processing Chain in the World Post Process Chain entry. We won't cover this because, although it's an easy way to get an effect to use in multiple levels, it is also the most complicated method and requires creating a post processing material, which can be very time consuming. We can also just change the default post process settings in the same menu. To apply a localized post process effect, we would irst make a post process volume and then change its properties. Let's start by adjusting the global settings in the Default Post Process Settings. Opening up the World Properties and expanding the Default Post Process Settings gives us access to a ton of options. The primary ones we'll want to play with are as follows: •

Scene highlights



Scene mid tones



Scene shadows



Scene desaturation

It is also useful to be able to adjust everything labeled with DOF, which stands for Depth of Field. The irst three affect colors, and as such use the same vector color format we've seen before. Try playing around with some of these numbers, and pay special attention to the scene shadows, as they'll have the most notable effect. Scene desaturation basically, as it says, takes color out of the scene. If we set it to 1, we'll have straight grayscale and 0 is the default. Depth of ield is an interesting one. It's the effect of having things you're focused on appear clear, while things either closer, further away, or on the edges of your vision appear more blurred. The two main values to play with for this are:

[ 44 ]

Chapter 4



DOF Inner Radius: It controls how wide is our cone of clear vision.



DOF Focus Distance: It controls how far we can see clearly.

Playing around with all of these values can lead to some dramatic results.

Summary In this chapter, we covered the basics of a number of ways to make your level feel more complete and interesting. It's not just a box on some ground to run around in. Now it's a run-down old building or a space station or whatever it is we wanted to make. The next step is adding some gameplay. To do this, we'll be looking at Kismet, UDK's visual level scripting language, and Matinee, UDK's in-game cutscene tool. Once we're inished with that, we'll be well on our way to having a playable game. [ 45 ]

Kismet and Matinee Now that we've got our level pretty much visually complete, we can start to set up some of the level events and anycut scenes that we might want. To do this, we'll use UDK's two more powerful tools, they are stated as follows: •

Kismet: It functions as UDK's visual and event-driven scripting language.



Matinee: It functions with craft in game cutscenes or control in game moving parts like the ever-popular moving platform or opening doors.

We'll be taking a cursory glance at these two tools and go through a couple of simple examples.

Introduction to Kismet Kismet is UDK's visual scripting language. It is primarily used to create eventdriven actions in the game. For example, if we wanted a light to lash upon the player entering a room, an enemy to spawn every 30 seconds, or any number of other things that are necessary and/or desirable in a game, we can perform those using Kismet. A secondary use of Kismet is as a simple diagnostic tool or other behind the scenes work. Kismet can be used to make a simple game timer, count the number of enemies alive in a level, or other simple things to help ine-tune a game's balance. It can even be used to control enemy behavior, to some extent. To get use to some of the basic maneuverability, we'll do a walkthrough of the classic programming exercise and create a sequence in Kismet that simply outputs "Hello World". The irst step, of course, is accessing the tool. To do this, click on the K icon in the top most toolbar or select View and then UnrealKismet. We'll be presented with a large, empty, and gray background. This is the Kismet environment.

Kismet and Matinee

Hello world Adding anything into Kismet begins as simply as right-clicking.

We'll see, as shown in the preceding screenshot, a list of options for adding different things by category which expand into lists of subcategories. We'll be going more in-depth into each of these categories and subcategories shortly, but for now, we'll walk through this example. Perform the following steps: 1. We will select New Event and then Level Loaded. This will give us the necessary starting point. 2. Next we'll right-click again, but this time we'll select Actions, then Misc, then Log. Now we'll have two nodes in our Kismet sequence, but we'll need to connect them. 3. So we'll left-click on the little black nub next to Loaded and Visible on the Level Loaded event, we added and dragged it to the In nub on the Log action. This will draw a line between our event and our action, and once it's connected, it will have a nice little arrow pointing in the direction that our sequence is lowing. In this case, it's pointing into the In nub. This indicates that our sequence will begin when our level is loaded and visible and will then run into the Log action. The Log action will output whatever data we tell it to the screen. 4. So the next step is to inform the Log action what data we want it to output. So irst we'll have to right-click on the Log action itself and then select the Expose Variable option followed by the String – String* option. This will pop a little green nub labeled String out to the bottom of the Log action.

[ 48 ]

Chapter 5

5. We'll then right-click on this green nub and select Create New String Variable. This will give us a green circle directly below and attached to the green String nub. This will be where we will tell our Log action what to display. 6. So we'll want to left-click on the newly created string variable and look in the Properties pane for the heading labeled Seq Var String and expand that downwards. 7. Here, we'll ind a ield titled Str Value where we'll want to type the string that we want our Log action to output. For the purposes of this example, we'll put Hello World in this ield. That's all. Now we've worked all the way through making a simple Kismet sequence. It didn't do much, but it has served it's purpose of getting us used to the basics of maneuvering the Kismet tool. To move a selected node in Kismet, hold Ctrl then left-click on it and drag it. To shift the entire Kismet workspace, like moving paper with writing on it instead of moving the words, we simply left-click on it and drag it. To draw a rectangle and select every node within the area, we'll hold Ctrl+Alt and left-click on it and drag it. To zoom in or out, hold left-click and right-click and drag in or out or use the scroll wheel.

A nice added feature of Kismet and, well, just about anything in UDK to be honest, is that we can select almost anything, hit Ctrl + C to copy it to the clipboard, and then if we hit Ctrl + V to paste it in a text editing program, it will paste as a text. Likewise, if we copy this text and paste it into the same tool that we copied it from, it will paste back in as it should be. So, for example, the hello world Kismet sequence that we just created will look something like this in text: Begin Object Class=SeqEvent_LevelLoaded Name=SeqEvent_LevelLoaded_0 MaxWidth=136 OutputLinks(0)=(Links=((LinkedOp=SeqAct_Log'SeqAct_Log_0')), DrawY=357,OverrideDelta=14) OutputLinks(1)=(DrawY=378,OverrideDelta=35) OutputLinks(2)=(DrawY=399,OverrideDelta=56) ObjInstanceVersion=3 ParentSequence=Sequence'Main_Sequence' ObjPosX=400 ObjPosY=288 DrawWidth=137 [ 49 ]

Kismet and Matinee Name="SeqEvent_LevelLoaded_0" ObjectArchetype=SeqEvent_LevelLoaded 'Engine.Default__SeqEvent_LevelLoaded' End Object Begin Object Class=SeqAct_Log Name=SeqAct_Log_0 InputLinks(0)=(DrawY=368,OverrideDelta=11) OutputLinks(0)=(DrawY=368,OverrideDelta=11) VariableLinks(0)=(LinkedVariables=(SeqVar_String 'SeqVar_String_1'),bHidden=False,DrawX=650,OverrideDelta=16) VariableLinks(1)=() VariableLinks(2)=() VariableLinks(3)=() VariableLinks(4)=() VariableLinks(5)=(DrawX=708,OverrideDelta=71) VariableLinks(6)=() ObjInstanceVersion=3 ParentSequence=Sequence'Main_Sequence' ObjPosX=615 ObjPosY=334 DrawWidth=131 DrawHeight=61 Name="SeqAct_Log_0" ObjectArchetype=SeqAct_Log'Engine.Default__SeqAct_Log' End Object Begin Object Class=SeqVar_String Name=SeqVar_String_1 StrValue="Hello World" ObjInstanceVersion=1 ParentSequence=Sequence'Main_Sequence' ObjPosX=611 ObjPosY=449 DrawWidth=32 DrawHeight=32 Name="SeqVar_String_1" ObjectArchetype=SeqVar_String'Engine.Default__SeqVar_String' End Object

If we really wanted to, we could learn to type code for Kismet directly, but there's really no reason to do so. This particular function enables us to, however, easily share Kismet sequences over Internet messaging programs. Now we'll go through the different categories of Kismet nodes.

[ 50 ]

Chapter 5

Events Events in Kismet are the triggering impulses that start at any sequence. Pretty much any action that would happen during gameplay is either predeined as an event or could be made into an event. The most common event types used are from the sub-categories of Actor, Level Loaded, and Player, which are illustrated in the following screenshot:

The event types in Actor are Anim Notify, Destroyed, and Take Damage. Anim Notify will allow us to place a lag in an animation so that when the animation reaches the time we have lagged, it would trigger this Kismet event. Destroyed and Take Damage are both fairly self-explanatory. If the actor we have attached to these events is destroyed or is damaged, it will trigger the respective events. We have already covered the Level Loaded event, so we won't go over it again. In the Player sub-category, we'll ind only Player Spawned. This might seem to be, generally, the same as Level Loaded, since the irst thing we as a player experience is the moment we spawn into the level. The difference is that the level actually loads very shortly before the initial spawning of the player. So if there's something that we want to be seen by the player or affect the player, it is best to use this event instead of Level Loaded, or else it may try to apply it to a player who has not spawned yet. This event can also be set up to be triggered by a player respawning after they have died. [ 51 ]

Kismet and Matinee

Most, if not all, event types have a property titled Max Trigger Count that defaults to a value of 1. If we want an event to only trigger, a set number of times, then we set this value to that number. If we don't wish to limit the number of times it can be triggered, we should set this value to 0. Another important property of events is the Re-Trigger delay. This, as its name implies, sets how long, in seconds, has to pass between the same event being triggered multiple times.

It is often times useful to set up an in-game object to act to trigger an event. In fact, there is a speciic Trigger class as well as a Trigger Volume class that we can place in our levels that are made to serve this purpose. The Trigger Volume class is easily found in the Add Volume list to be placed using the methods we've already covered, and the Trigger actor can be placed by right-clicking and selecting Add Actor and Add Trigger.

To make an event using this trigger, or any actor for that matter, we must irst have it selected in our level and then right-click in the Kismet workspace. Then we'll select New Event Using Trigger, and we'll be presented with some options. For Triggers and Trigger Volumes, the most common event types are Touched and Used. Touched triggers are required when the player enters into a set distance of the object's location, and Used requires the player to hit a button within a different set range, usually this button is defaulted to E. You can set the range needed to touch the trigger by scaling it in the same way you scale anything else. To set the range from which you can use a trigger, you have to set it within the Used event itself. For example, if we changed our Hello World sequence to be triggered by touching a trigger in a level, we can start it by placing a trigger somewhere in our level. Then we will create a new event using [The Trigger] with the selected trigger we just placed, right-clicking in the Kismet workspace and navigate to New Event Using [The Trigger] | Touch and we will get connected to the sequence we made previously. The end result will look something like the following screenshot: [ 52 ]

Chapter 5

Actions Now that we know how to get the ball rolling on a sequence, we're going to take a look at the different things we can perform. The actual actions that can be done through Kismet are generally found in the New Action category. Surprising, isn't it?

[ 53 ]

Kismet and Matinee

This is where the bulk of the most useful Kismet functionality is, and as such, there is far too much to cover fully. The best way to learn most of these is just looking through and messing around with them to see what they can do. That being said, there are certainly a few worth mentioning here. In the Actor subcategory we'll ind a lot of useful functionality for getting and/or setting information about things in our map. This sort of information can be very useful in certain situations. This is also where we'll ind Actor Factories, which we'll be using later to spawn enemies into our game. In the Level subcategory we'll ind the actions used for level streaming. This functionality is very useful, for example, if we made a massive world with interiors and exteriors but our world was so large and complex that most computers couldn't run it very well and we need a way to optimize it. Using level streaming, we can cut our level into pieces such as inside and outside, and we can stream these levels in or out as we need to. So when we go inside, we can load our interior levels and unload our exterior levels, and when we go back outside, we load our exterior levels and unload our interior. The Math subcategory contains all of the mathematical operations you can perform. As Kismet is a scripting environment, which is to say somewhat simpliied programming, there are many places where math is necessary and otherwise useful. The Misc subcategory is where we found our Log action before. We'll also ind such useful actions as Delay, which can be used to put a pause between the completion of one action and the start of another. Gates are also found here, and they act as a nonspeciic continuation check. Basically, a Gate can be set to be Open or Closed via either a Boolean variable—which holds either a value 0 for false or 1 for true—that can be exposed, a Toggle nub, or an Auto Close Count property. If a Gate is open, then the sequence chain will continue from its Out nub. If it is closed, it won't continue down that line. If we hold G and then left-click in the Kismet workspace, it will place a gate where we click.

Toggles are also worth mentioning. If we have a light that will be turning on and/ or off, or really anything that will turn on and/or off, particularly if it is based on a trigger, a toggle will be the way to do it. This action is pretty straightforward. There's a nub for Turn On, a nub for Turn Off, a nub to Toggle to whichever state it isn't currently at, and a nub on the bottom to plug in the target object.

[ 54 ]

Chapter 5

If we hold T and then left-click in the Kismet workspace, it will place a toggle where we click.

Conditions Conditional statements are where Kismet really starts to feel more like proper programming. These are used to compare variables and take different actions based on how they relate to each other; there are also used for counters, which makes iterating through a loop for certain number of times simple and adaptable.

UDK also provides us with a number of speciic and non-variable conditions to allow us to check for things like"is this object alive?". They really do come in handy for some of the more involved Kismet we'll be using.

[ 55 ]

Kismet and Matinee

Variables Getting more into the areas of Kismet, we should quickly go over variables.

These are the little circles that can represent numbers, in-game objects, and pretty much anything we'll be able to manipulate in Kismet. There are many different kinds of variables available to us. Some of them are listed as follows: •

Int: This stands for integer and is a whole number such as 1, 5, or 10.



Float: This is another number but it includes a decimal, so it can be numbers such as 1.5, 2.7, or 9.99.



Bool: This variable type only has two possible values—true (1) or false (0).



String: This variable is text-based characters. Hello World was, for example, a String.



Player: This variable will represent one or all of the game's participants.

[ 56 ]

Chapter 5



Vector: This variable type is three numbers representing X, Y, and Z values.



Named Variable: This is used to have a variable referenced in multiple places without having to draw connection lines all over the place. Primarily used for organization or when using subsequences. Holding I, F, B, P, or N and left-clicking in the Kismet workspace will create an int, loat, boolean, player, or named variable, respectively.

Subsequences Subsequences are basically Kismet sequence within a Kismet sequence. Most of the time they are used for organizational purposes, as it allows us to condense any complicated and messy looking sequence we've come up with to look like it was some pre-existing Kismet action.

Within a subsequence if we want to pass variables back and forth to either a parent sequence, meaning a sequence to which the current sequence is a subsequence, or a subsequence, then we can either use a Named Variable or an External Variable. An External Variable is a variable that, once plugged in, will show up as a nub on the bottom of our subsequence when viewed from its parent sequence. To fully integrate a subsequence into our game, we'll possibly also want to add the in and out nubs that all the other Kismet actions have. The In hook can be found under Events and is called Sequence Activated. The Out hook can be found under New Action, Misc and is called Finish Sequence.

[ 57 ]

Kismet and Matinee

Matinee Now that we have a basic understanding of how to use Kismet, let's look at one of the tools we can readily access from within Kismet: Matinee. Matinee is a tool used to make things move or change in a cinematic way in a level. If we need a door to slide open? use Matinee. If we need something to spin or a light to lash? use Matinee. If we need to have a lythrough of your level before your game actually starts? use Matinee. You can see where this is going. So, let's go ahead and access the editor by right-clicking in the Kismet environment and then selecting New Matinee. Then, we simply double-click on the Matinee box and we'll be whisked away to the magical land of cinematic editing.

[ 58 ]

Chapter 5

In the preceding screenshot of the Matinee editor we can see all of our important parts. We've got the toolbar at the very top where we can control the playback of a preview of our Matinee in our viewport windows, the Matinee Curve Editor where we can ine-tune anything that can be represented as a changing value over time, then we have the Track Editor which allows us to add different sorts of tracks based on what we're controlling. Adding a track or a group in Matinee is as simple as right-clicking in any empty space right above the time display and selecting what sort of track or group we need to add. Adding a keyframe, which is a set point in the Matinee where values are set for the Matinee to move between, is as simple as selecting the track and pressing Enter. Right-clicking on a keyframe allows us to manually enter a time and, if the track property does not contain a vector, we can also manually set a value. This is another one of the tools where it's good to just try it out and learn by experimenting. We'll be walking through a speciic example shortly, but this tool is so powerful and deep that it would likely take a lot more time to cover it in depth than this book is prepared to do.

Director If we were to do anything using cameras, we'd likely want to use a director group. This allows us to, through setting keyframes, switch between multiple cameras if we have the need. It also lets us control some effects such as slomo or slow motion and fade. To properly use the director group, we'd also need to make at least one camera group for it to use in a keyframe. A camera group, by default, contains a movement track, which controls how the camera moves over the course of the Matinee in terms of X, Y, and Z location values as well as Roll, Pitch, and Yaw rotation values. It also by default contains a track titled FOV angle, which controls the Field of View of the camera. Clicking on the little camera icon next to a group allows us to be placed in a irst person view of whatever is plugged into that group's nub in Kismet. This is especially handy when we're dealing with cameras, as it shows us exactly what the camera is looking at and, if we're-editing a keyframe, it allows us to get the placement of the camera just where we want it using the same maneuvering tools we use to move about in our level in the viewport.

[ 59 ]

Kismet and Matinee

Editing a camera's motion track can be an interestingly fun process. Usually we'll want a fairly smooth motion, so the fewer keyframes we can have, the better it will be. After we have some rough keyframes setup, we'll likely realize that it isn't moving between the points quite how we want. This is where the Curve Editor will come in handy. To view the location curve of any movement track, we'll simply need to click on the box to the right of the track label. On movement tracks, by default, there are two such boxes. One that defaults to on and is colored green, and one that defaults to off and will show up yellow when we check it on. We want that second box. Clicking on it will display the X,Y, and Z location values for the given track in the Curve Editor as well as editable points where our keyframes are along the timeline. Right-clicking on one of these keyframe points allows us to manually set the associated value. If we want to adjust the rotation on the Curve Editor, we have to look in the Properties of the track and ind the checkbox marked Show Rotation on Curve Ed and check it to be true. The Curve Editor can get a bit crowded just from one track's location and rotation curves. The components can be individually turned off by clicking on the colored boxes below the curve label. The slightly brighter red, green, and blue boxes represent the X, Y, and Z location curves while the slightly darker red, green, and blue boxes represent the rotation curves around the same axes. For a static mesh actor to be movable via Matinee, it has to be either brought in or converted to either a mover or an interp actor. This can be done by right-clicking on the actor, if it's already in the level, and selecting Convert and then Convert to Mover. Something to keep in mind though is that movers by default have no collision, so we'll have to open up the newly made mover's Properties, search for Collision Type and make sure it's where we want it. For example, a door that you want to slide open should still have its Collision Type, set to COLLIDE_BlockAll.

Because it's always easier to understand with a working example, we're going to walk through a basic example of a platform raising and lowering. It can just be a new map to test things out on: 1. First we need to pick a Static Mesh Actor to use as our platform. StaticMesh'NEC_Roofs.SM.Mesh.S_NEC_Roofs_SM_TiledSolid'

is a good choice. 2. Next we add this Static Mesh Actor to our map where we want our platform to be. To do this we right-click and select Add InterpActor: [Our chosen Staitc Mesh Actor] and place it where we want it.

[ 60 ]

Chapter 5

3. Interp Actors, by default, have no collision. Since we plan on using this platform as an elevator, we need to change that. So if we right-click on the platform and open up its Properties and then use the Search bar to search for Collision Type, we'll see a drop-down menu that we'll want to set to COLLIDE_BlockAll. 4. Now that we've got our platform placed, let's make it move. In the Kismet workspace, right-click and select New Matinee. This will open up the Matinee Editor. 5. Next, we'll want to add a new group. To do this, we'll right-click in the left pane of the Track Editor and select Add New Empty Group. 6. Now that the group is created, we have to add a track, To do this, we'll rightclick on the group and select Add New Movement Track. 7. At this point, if we look at the Kismet workspace again, we'll see that a new nub has appeared that is labeled with the name we gave to the group. Now, if our platform was selected in the level when we made the group, it should have automatically been added and connected. If it hasn't been, we'll want to go and select it, right-click on the nub that was created on the Matinee box and select New Object Var Using [The Platform Actor]. 8. For simplicity's sake, we'll have our platform go up, wait 5 seconds, come down, wait 5 seconds, and repeat. So we'll have to extend the default playtime of the new Matinee from 5 seconds to 15 seconds. 9. Next, we'll make two keyframes by pressing Enter. They'll appear at whatever time we play line at, but we'll want them at a speciic time so we'll right-click on each one and select Set Time and set one to 5 seconds and the other to 15 seconds. 10. Keyframes are all well and good but if the position of the platform isn't different then it won't move. So we're going to select the keyframe that we placed at 5 seconds by left-clicking on it. 11. With the keyframe selected, we'll need to go back into the level and raise the platform to the height we want it to end up at. 12. Now, without moving the play line, we'll make a copy of the 5 seconds keyframe and set it to 10 seconds the same way we set the time on the other keyframes earlier. This completes the basic movement of up, wait 5 seconds, down that we wanted; now we just have to make it repeat itself. 13. Closing the Matinee Editor and going back into the Kismet workspace, we'll want to add a delay. So we'll add the Delay action and set the time to 5 seconds. We'll run a connection between the Completed tab of the Matinee box and the Start tab of the Delay action. Then, we'll run another connection from the Finished tab of the Delay action back to the Play action of the Matinee box. [ 61 ]

Kismet and Matinee

14. That pretty much does it for the looping elevator platform, but there's two more things we have to do. First, if we click on the Matinee box and look at it's Properties, we'll ind a checkbox labeled Rewind On Play. This box, when checked, will, as it states, rewind a Matinee when something triggers the Play tab, like our Delay action will over and over again. 15. The last thing we'll need to do is tell this looping sequence when to start. Seeing as this is just an example, how we start the loop is arbitrary, so let's use a Level Loaded event and run a connection from the Loaded and Visible tab to the Play tab on the Matinee box. Now we've got a rising and lowering platform! This gives us a fully functional elevating platform that will, when the Matinee is played, raise and lower. It would be beneicial to build off of this Matinee and dig deeper independently into this tool to fully grasp how much it can do.

Summary Now we have a basic grasp of how to use Kismet and Matinee. We didn't go into some of the really awesome things it's capable of, but we've got the knowledge we need to dig around and igure them out with experimentation. In the next chapter, we'll cover how to set up our level so that enemies, when they're added, will know how to navigate around the level without bumping into things or getting lost.

[ 62 ]

AI Navigation, Pathing, and Enemy Setup Now that we've got our level built out the way we want it visually, and we also have a cursory understanding of the awesome things we can do using some of UDK's powerful tools, it's time for us to take a look at a less lashy part of making games: Pathing. Pathing is a term used to describe how enemies or anything that moves, is based on programmed Artiicial Intelligence, or AI. Using different kinds of programming algorithms that take things like obstacles into account, they know where they are allowed to walk and how to get from point A to point B. It's a very important part of making sure that a level is playable, but can be very time consuming to make sure that it is start properly. After we've set up where our enemies can move about, we'll set to actually bringing some enemies into the world using Kismet. We'll also take a look at controlling their behavior in our level using a combination of Kismet, Path Nodes, and some very basic Nav Mesh work.

Pylons and navigation meshes The irst step is to set up proper pathing to place down Pylons. Pylons are actors in UDK, which when we click on Build Paths, will explore within a set distance of the actor and construct what is called a Navigation Mesh, or Nav Mesh for short. The purpose of the Nav Mesh is to create a system of points along the ground adhering to settings that we can adjust in the Pylon actor. To place a Pylon in the map, we'll simply right-click on it, select Add Actor, and then select Add Pylon. Easy enough, and now we've got the only truly necessary piece to make our pathing.

AI Navigation, Pathing, and Enemy Setup

If we were to click on Build Paths now, the game would take it's time and create a Nav Mesh with all the default values. Depending on the size of our map, this may be all we need, but most likely, some modiications and additions will be needed.

If we open up the properties of the Pylon by selecting it and pressing F4, we'll see a number of options, but the ones we're mostly concerned with are the ability to assign an expansion volume and set an expansion radius. If we were to build paths using purely the default settings and our level was larger than the default size of the Pylon's expansion, we could toggle the visualization of our Nav Mesh by hitting P in the navigation window. In this instance, we'd see a cube formed around our Pylon but not extending to our entire map. This would either be corrected by adding more Pylons or increasing the expansion radius. The expansion radius can be increased from its default of 2048 up to 6000. If this remains not enough coverage space or we ind that it is taking an inordinate amount of time to rebuild pathing, we can add more Pylons.

[ 64 ]

Chapter 6

Adding more pylons will grant us with two important abilities, which are stated as follows: •

First, and most obvious, it will allow us to expand to a greater volume than that represented by a sphere of radius 6000 units. This is clearly important if we're making massive levels.



Secondly, it allows us to break up our Nav Mesh into parts that we can rebuild individually by right-clicking on Build Paths. This means that for example, if we split our level up into 4 parts and need to make changes that affect pathing (which UDK will inform us of when we are playing in the editor), we won't have to rebuild all of the pathing, but can instead rebuild only the sections we changed.

Depending on the speed at which our computer can rebuild pathing, this can be a huge time saver.

[ 65 ]

AI Navigation, Pathing, and Enemy Setup

Another problem that can sometimes present itself with Pylons is that, as explained previously, it builds out into a cube. This, in many cases, will not be the shape of your pathable area. Maybe we want to restrict pathing to the interior of a building, but the building is a very uneven rectangle. If the expansion radius is set to the length of one of these sides, then the Nav Mesh would either be too big or too small on the other side. This issue would only be worse depending on the shape of the area. To ix this problem, we will utilize the special type of volume called a NavMeshBoundsVolume. This way, we can restrain our Nav Mesh to pretty much any shape we'd like. To use a NavMeshBoundsVolume, we perform following steps: 1. We'll set up our builder brush the same way we would for any volume. 2. Then we'll right-click on the Add Volume button and select NavMeshBoundsVolume. This will place our volume in the level. 3. To assign it to our Pylon, we'll need to open up the Pylon's Properties. 4. Left-click on the Lock Selected Actors (indicated by the image of a padlock) button in the upper-right of the widget then select our NavMeshBoundsVolume. 5. Then click on the little green arrow next to the expansion volume ield. 6. Now, when we build pathing from this Pylon, it will be constrained by the NavMeshBoundsVolume we've applied.

[ 66 ]

Chapter 6

As we can see in the preceding screenshot, there are some holes and jagged edges in the Nav Mesh. Mostly if not all of these are due to rougher Terrain, and some of them aren't truly holes, but the Nav Mesh is simply intersecting with the ground. If we have areas that should be walkable areas but, for whatever reason, the Nav Mesh does not recognize them as such, we can patch the area with a well-formed blocking volume and pretty much nobody would ever notice that we would actually walk a few inches above the ground in an area. In many games, this is similar to how stairs are handled: utilizing a ramp instead of having collision shaped precisely to the stairs.

Path Nodes

Unfortunately, a Nav Mesh can be a very tricky thing to get working properly for a variety of reasons so, while it is important to know how to make them and make them well, we're going to continue in our example using a different and more userfriendly pathing system: Path Nodes. Path Nodes can potentially take some time to lay out properly, but without using any UnrealScript, they are much simpler to work with. The idea is that we're going to use a blanket of Path Nodes to simulate a lot of the same functionality of a Nav Mesh, just with fewer headaches. Making sure our Path Nodes are distributed well is important, as they should all link to at least two other Path Nodes so as not to create dead-end scenarios. The easiest way to do this is to just create an evenly spaced grid of Path Nodes. The steps for the same are as follows: 1. To do this we'll irst have to place one by right-clicking and selecting Add Actor and then Add Path Node. 2. We'll then want to move this way above our ground level and switch to Top Down Perspective View. 3. If zooming out so that our whole map is visible makes the Path Node hard to see, we can open up its Properties and go to Display and then set Draw Scale to a signiicantly larger number until we can see it clearly. [ 67 ]

AI Navigation, Pathing, and Enemy Setup

4. From here we can change the drag grid snap settings to a somewhat larger number like 512 or 1024. 5. Then we'll simply duplicate Path Nodes by holding down Alt and dragging a Path Node using the Translation widget. 6. Once we have our grid complete, we can right-click on one of the Path Nodes and select Select and then Select All PathNode Actors. 7. Once we have all of them selected, we'll hit End, which will land them all on the closest ground. 8. If we've made a simple, one-story level, then all we have to do now is build paths and we'll have our functional navigation area. If our level is more complicated by having multiple loors on top of one another or any sort of roof, we'll have to go about placing more Path Nodes by hand to ill in any gaps if present. 9. Now we'll build paths and hopefully see no errors or warnings, and then, when we hit the P button to show the paths, we'll see a nice, interconnected grid between all of our path nodes as in the following screenshot:

If we do get errors or warnings relating to Path Nodes, usually it's OK to just remove the Path Nodes in question.

[ 68 ]

Chapter 6

Enemies

Now that we've made our area navigable by AI, let's pop a few enemies into our level and see how they do. We'll go through a few examples of basic AI commands using Kismet and we'll work our way up to somewhat more complex survival mode.

Spawning enemies The irst step to having some good enemy behavior in our game is to get the enemies out there on the ield. There are primarily two ways to handle this. We can either perform one of the following: •

Spawn the enemies dynamically using Kismet



We can make an Archetype and place instances of it in our level where we want our enemies to be [ 69 ]

AI Navigation, Pathing, and Enemy Setup

Both approaches have their own merits depending on what sort of game we're making. If we wanted our enemies to never stop coming, or stopping them to be based on a number killed or a time survived or some other event, then we would clearly choose the dynamic Kismet option. If, however, we were making something akin to a platformer, or any other game type that would have very ixed, static enemy encounters, then we could just as easily place them in the level. Generally, it is better practice to spawn enemies dynamically. Dynamically spawned enemies can do everything that placed enemies can do, but not the other way around. So that is the method we're going to focus on. By default, UDK makes a level that doesn't have a game type assigned to it. For the default bots to function, we'll need to change the game type. To do this, we need to click on View then World Properties. Once in World Properties, we'll scroll down to where it says Game Type and change the Default Game Type and Game Type for PIE to either UTDeathmatch or UTTeamGame. For the survival example we're going to be making, we should pick UTTeamGame. The key to spawning enemies using Kismet is a Kismet sequence called an Actor Factory. These actor factories can be used to spawn weapons, vehicles, or a number of other things, but for this example, we'll be using it to spawn enemies.

[ 70 ]

Chapter 6

As we can see, to place one of these actor factories into Kismet, we right-click in our Kismet window and navigate to New Action | Actor | Actor Factory. Now we have to set some speciic settings to get it to actually work: 1. First we'll need to set what type of factory we want. To select this, we'll click on the blue downward-pointing triangle next to the factory ield. This will give us a list of factory types to choose from, and we'll want to choose UTActorFactoryAI. There's another ActorFactoryAI on the list, but it isn't the one we want. 2. With that selected, we'll then want to click on the drop-down of the populated factory menu. The two ields we'll need to set in here are the Controller Class and Pawn Class. We'll set Controller Class to UTBot and Pawn Class to UTPawn. That's all we need to set in the Actor Factory to spawn a basic enemy in our map. 3. Now we need to simply choose one of our Path Nodes to be a spawn point and trigger the Spawn Actor node on the Actor Factory with a Level Loaded/ Loaded and Visible event. When we've done this, we should have something that looks pretty much like the following screenshot:

[ 71 ]

AI Navigation, Pathing, and Enemy Setup

As it is instructed previously the empty Object variable in the example image, we simply need to assign a spawn point, usually represented in the map by a Path Node, into the Object. To do this, we need to irst select the Path Node we wish to use in the level and then we need to right-click on the Object variable and select Assign [selected path node] to Object Variable(s). This sequence will spawn a functional bot.

Enemy movement Now that we've spawned an enemy, we may notice that he's not doing anything. Well that's because we haven't told him to do anything. Let's get him running around a little bit. To do this, we're going to set up a Kismet sequence that will make him move back and forth between two points: 1. Starting from the sequence that we made just a minute ago to spawn our enemy, we're irst going to right-click on the triangle labeled as spawned and select Create New Object Variable. Anytime in Kismet that we are presented with a triangle coming out of the bottom of a sequence, that means that it is something output by the Kismet sequence.

2. This Object variable will contain the information for the enemy we spawn and allow us to refer it to give it instructions. What we'll want to do next is right-click on our Kismet window and navigate to New Action | AI | Move To. This sequence's purpose is right in its name. It tells an AI-controlled entity to move to a deined actor. 3. While we've got it without any connections, let's go ahead and copy and paste it so we have two of them. 4. Now let's connect these two Move To Actor sequences in a chain to the end of the Finished tab on our Actor Factory. 5. Now link the Finished tab of the second Move To Actor back around to the In tab of the irst. 6. While we're dealing with the In tabs, let's right-click on each In tab for our Move To Actor sequence objects and select Set Activate Delay, which will pop up with an information box with a default of one second in it. 7. Let's click on OK. This will set a one second delay whenever the In tab is set to be used by Kismet. It's a good idea when dealing with AI controls to set a bit of a delay between each action just to be on the safer side.

[ 72 ]

Chapter 6

8. Now that we've got two Move To Actor sequences, we need to link up the Target nubs on both of them to our Object variable that we attached to the spawned output of our Actor Factory. Doing this lets our Move To Actor sequences know that it needs to pass this command to our spawned enemy. 9. Now, we should choose a second Path Node to connect to the Destination nub of our irst Move To Actor sequence. We'll just connect the same one we used for the spawn point to the second Destination nub. 10. We'll also want to hook in our Player variable to the Look At nubs. Now we have a sequence that spawns an enemy, moves him to a second location, then moves him back. 11. To have him endlessly run back and forth, we need to simply attach the Finished tab of the second Move To Actor to the In tab of the irst. Once we're done, we'll have something that looks like the following screenshot:

[ 73 ]

AI Navigation, Pathing, and Enemy Setup

We can see that as we follow the line from the Level Loaded event, it will go straight into spawning a bot. This node uses the exact same settings as the previous example, so to follow along, just build out from the last example. One difference is that we've attached another Object variable to the Spawned output tag. When this Actor Factory spawns a bot, it will output that object through the Spawned output tag into that Object variable, allowing us to access it for other purposes. In this example, that purpose is merely to have it run back and forth between two points. To control this movement, we've set up two Move To Actor sequences and connect them to the Finished tag of the Actor Factory. The Move To Actor actions are found by going to New Action, then to AI. To look at the Kismet action is all we need to igure out what goes where. The Target tag needs to be attached to what we want to tell to move, the Destination tag needs to be attached to where we want the target to move, and the Look At tag tells the target what direction to face as it moves. If we want the target to look where it's going, we can attach the same Object variable as we used for the Destination tab. In our example, we have the target looking at the player as he moves. The Player variable is the only variable in this example that needs a property changed. By default, when a Player variable is added to Kismet, it refers to all players. To have it refer to a speciic player, in this case, player 0, which will basically be the irst player to spawn in, we must simply select the Player variable and, in the Properties pane, uncheck the box labeled All Players. We can set the number of the player using the Player Idx ield in the same pane.

Combat Now we have learned the basics of spawning and moving enemies. Let's give them a gun and put them against us. It will make things more interesting. To arm our opponent, all we have to do is select the Actor Factory and, where it says Inventory List, click on the green plus sign and then select a weapon from the drop-down menu. Let's select the UTWeap_RocketLaunder_Content. Again, it will make things more interesting. If we start our level now, we'll see a spawned enemy with a rocket launcher running back and forth. He won't shoot at us though because we haven't set his team to one that views us as enemies. So again, let's look at the Actor Factory properties and where it says Team Index, let's change that to 1. This will cause our enemies to spawn on the blue team, where we, as the player, spawn on the red team. Now our enemy will ire on sight.

[ 74 ]

Chapter 6

Gameplay Now that we know how to spawn enemies that will move around and attack us, let's implement some gameplay. To be completely honest we have all the tools we need to get started, it's just a matter of coming up with an idea and trying and testing it in parts until it behaves how we want it. For example, if we wanted to make a game type that started by spawning one enemy every 30 seconds at a random location which would then start roaming the map to ight the player and slowly, over time, spawned them faster and faster until it is spawning multiple enemies every second, we can do that. If we want it to give these enemies unlimited rocket launcher ammo, we can do that. In fact, if we were to set up a game that behaved in that way, spawning more and more enemies faster and faster and giving them rocket launchers that, when we (the player) kill them we could then pick up and just try to stay alive as long as possible, it would look something like the following screenshot:

[ 75 ]

AI Navigation, Pathing, and Enemy Setup

If we were suppose to simply look at this image, it looks as though everything that this Kismet does is very simple, neat, and tidy. Well, unfortunately, that's not exactly the case. It's neat and tidy because a lot of time was taken to make it neat and tidy. Kismet, in many ways, is very similar to traditional programming. Many programs can be written to be all contained in one massive function. This would be terribly complicated, hard to read, and generally a bad form. A Kismet sequence can be broken up and organized as a system of subsequences in a similar fashion as functions. They can be passed as input from and return as output to variables. They can even be nested. To easily make a subsequences, simply right-click on the Kismet workspace and select Create New Sequence. UDK will then ask us to name our subsequences, and it will create it for us. It will be listed in the Sequences pane of the Kismet window, and we can jump to it quickly that way. Alternatively, double-clicking on the subsequences in the main pane of the Kismet window will open it. This Kismet example is included with the downloadable code accompanying this book. To follow along, copy and paste the text marked as Chapter 6, Gameplay Example into the Kismet window.

Following the earlier instructions will net you a box without any connectors on it. There will be no In, Out, and Variable tabs like those shown in the previous image: 1. The In tab can be added by adding a New Event | Sequence Activated into the subsequences. It can be named whatever we'd like via its properties. 2. Adding an Out tab is similarly accomplished by adding a New Action | Misc | End Sequence to the subsequence. It too can be renamed using its properties. 3. Adding Variable that can be passed in or out of the subsequencecan be given tabs by adding external variables to the subsequence. These can be added by selecting New Variable | External Variable. 4. When an external variable is initially created, it has no type. We can set the type within its properties, or simply as soon as it is connected to a Variable tab, it is made to represent the appropriate type of variable. These can also be renamed using the Variable Label ield in the properties. The variable label indicates what will show up on the subsequence container in the parent sequence above the variable tab that feeds to or from the external variable.

[ 76 ]

Chapter 6

The two exceptions to Kismet being able to be structured like regular code are instancing and recursion. All Kismet variables behave as global variables, which is to say that if you change it, even in a subsequence, it will affect anywhere else it is used. As for recursion, without localized variable instancing, it would be either impossible or extremely complex to get a sequence to recall itself with new values without affecting the original values. The point is, be careful with your variables.

This Kismet sequence is split up into four distinct subsequences. Each one handles one part of the greater gameplay system. They are described as follows: • • • •

SpawnEnemies: As the name implies, it handles the spawning of enemies. EnemyTrackingListMaintenance: It keeps a list of all of the living enemies in the map. Movement: The preceding subsequence does this so it can iterate through the list to give movement instructions to each enemy from the third sequence. DificultyIncrease: It is responsible for monitoring and changing how frequently enemies spawn and how many spawn at a time. As the game progresses, enemies will spawn irst more frequently and then more of them will spawn at a time. This is a simple way of increasing the game's dificulty as it goes on.

Now we'll take a look at the insides of each subsequence and go over how they are set up. First is SpawnEnemies:

[ 77 ]

AI Navigation, Pathing, and Enemy Setup

In this subsequence, we may notice that it is not terribly dissimilar from our earlier basic spawner example. The crux of the sequence is the actor factory, which is set up the same as the actor factory in our basic combat example we walked through earlier. The truly important distinction is how it chooses a spawn point. Rather than being fed one spawn point, we need to let it choose one at random from some number of them. This will keep our enemies spawning consistently, as if one enemy is occupying the space where a spawn point is located, more enemies will not spawn from that spawn point. To handle this, the subsequence is given an object list using the way of an external variable. The contents of this object list should be all of the spawn points we want enemies to possibly spawn at. Within the subsequence, the irst thing that is done is the object list is accessed by navigating to New Action | Object List | Access Object List. In the example, we've told it to pick a random entry, which it will then pass out of the output object connector to another external variable that is also passed to the actor factory's spawn point connector. The actor factory, it is worth noting, also takes an external variable integer value that plugs into the spawn count connector. This controls how many enemies it will spawn this time around. After the actor factory spawns its appropriate number of enemies, it grants them ininite ammo using the way of New Action | Pawn | Ininite Ammo action. And that's all this sequence does. Next, we'll look at the EnemyTrackingListMaintenance subsequence:

[ 78 ]

Chapter 6

This subsequence is a little bit more complex. The function of this subsequence is twofold, relating to an object list keeping track of every living enemy in the map. First, it is meant to add the most recently spawned enemy to the list: 1. This is accomplished by passing the most recently spawned enemy as an external variable from the SpawnEnemies subsequence to the primary sequence and then into the EnemyTrackingListMaintenance subsequence, where it plugs into the object reference connector of a New Action | Object List | Modify ObjectList action. 2. Also attached to this action are external variables for the object list that will contain all of the living enemies and an integer that will contain the current size of that list. 3. This action goes out into an Int Counter, which behaves exactly like a regular Int Comparison, except that every time it is passed through, it will increment the integer variable attached to the A tab. The value it is to be compared to is that integer representing the size of the enemies list. 4. While the counter variable is less than the list size, we have set up an access object list by navigating to New Action | Object List | Access ObjectList action which takes the current counter variable into the index connector, passes the output object, which will be the enemy located at that index of the object list, to a New Condition | Is Alive check. 5. If the enemy is alive, return back to the counter to check the next one in the list. If it is not alive, then it will be passed to another modify object list action, this time with the remove from list action being utilized. 6. Once the counter variable catches or surpasses the integer tracking the number of entries in the list, then the iteration is complete, the counter is set back to -1, not 0, by navigating to a New Action | Set Variable | Int action, and then completes the sequence.

[ 79 ]

AI Navigation, Pathing, and Enemy Setup

Now, let's take a look at the Movement subsequence. It should look fairly familiar at this point. Have a look at the following screenshot:

This subsequence operates in three simple steps, they are as follows: 1. The irst step is it iterates to the next enemy in the list, which has been passed as an external variable into this subsequence as well, using the same Int counter system we went through in the previous subsequence. So as long as the counter variable is less than the size of the list, it will use an Access ObjectList action to reference the individual enemy at that Index. 2. Secondly, it will grab a random entry from the list of spawn points, which should be Path Nodes. 3. The third and inal step is using a Move To Actor action to tell the Target enemy variable to go to the Destination Path Node while looking at the external variable which, in this example, is the player.

[ 80 ]

Chapter 6

Once it has inished this move to action, it exits the subsequence. It would also exit the subsequence if the counter met or surpassed the length of the list after setting it back to a value of -1. It should be noted, with a quick glance to the parent sequence, that this subsequence, upon exiting, simply goes right back into itself. This is to keep the cycle of enemies choosing new places to move towards going constantly, so the chances of any enemy standing still is slim.

The preceding screenshot represents the inal subsequence. It is labeled as DificultyIncrease, and that's what it is in charge of. In this example, there are two values that directly control the current dificulty: •

Time between spawn waves



How many enemies spawn per spawn wave

[ 81 ]

AI Navigation, Pathing, and Enemy Setup

Each of these, along with two controller values (minimum delay between spawn waves and maximum enemies to spawn at once), are represented by external variables in this sequence. Upon the start of the subsequence, a Delay is triggered that ticks off the current value for the delay between spawn waves. Once it is completed, it checks to see if it is at or below the minimum value. If it is not, it decreases by navigating to New Action | Math | Subtract Float action and ends the sequence. If the delay value has already hit the minimum, it continues towards checking to see if the number of spawned per spawn wave value has reached its maximum. If it has not, then it increments the value and ends the subsequence. If it has, then it simply ends the subsequence. It should be noted that this subsequence, upon exiting, feeds back into the initial SpawnEnemies subsequence, forming a loop. To form a truly complete game, Kismet would have to be added to end this loop upon conditions being met for either winning or losing. That will make for good practice. All that would need to be done to make this Kismet sequence fully functional is to add the Path Nodes from our map to the object list variable that is labeled. From there we can play around with and add to this sequence and its outermost variables until it plays how we want it to play.

Summary Now we have a pretty solid foundation of using Kismet and Path Nodes to shape our game in terms of enemies. With this foundation and the level of comfort we have been gaining with UDK and its tools, we can continue to expand on our knowledge to create some wonderful games. In the next chapter, we'll touch upon some of UDK's physics tools. This will include having things explode in our game world, walls that can crumble when hit by something, and how UDK makes ragdolls out of skeletal meshes.

[ 82 ]

Physics Now that we've got a whole bunch of enemies running around shooting rockets at us, why don't we give them some more things to blow up? Maybe we can hide behind some walls for a little while until they're blown to smithereens by enemy ire, or add some barrels that bounce around causing mayhem. Depending on what sort of world we're building, we can even add gravity ields and invisible lifts. In this chapter, we're going to be covering a vast expanse of what UDK has to offer by way of physics assets. Physics assets, as this book will refer to them, include anything that isn't fully controlled entirely by predetermined methods like animations or motion graphs. Physics assets are instead items in the world that are either acted upon or do themselves act upon other objects in the game at times that are often not known until they happen. For example, if our game had an explosive barrel, and when it exploded, it pushed players and/or other items away from it, then those items, as well as the force pushing them, were most likely physics assets. In theory, they could have been animated before hand, but unless it's a cinematic cutscene, there aren't many games that would handle such an event that way. UDK offers a wide variety of physics assets; they are: •

Fractured static meshes



Simple physics actors



Complex physics actors or ragdolls



Force actors



Physics volumes

In this chapter, we'll be taking a look at the uses and implementation of these types of actors to bring a little more lavor to our game.

Physics

Fractured static meshes Fractured static meshes are, as the name suggests, static meshes like walls, pillars, or other meshes that have been sliced up into chunks using the Fracture Tool, which is found in the Unreal Static Mesh Editor under Tools, as shown in the following screenshot. The Unreal Static Mesh Editor can be accessed as follows: 1. Right-click on a static mesh actor in the Content Browser tab; for this example, we'll be looking at a standard wall mesh provided by UDK. 2. Select Edit Using Static Mesh Editor....

Fractured static meshes, in general, are not in any way necessary for most forms of gameplay. They have recently been used in some games to show off the power of the engine, as creating and rendering a large number of chunks can be a very graphically intensive undertaking. This resource drain is the reason that they haven't been widely used in a lot of games.

[ 84 ]

Chapter 7

To create a fractured static mesh within the Unreal Static Mesh Editor's Fracture Tool, there are a few settings we want to take a look at. First and foremost, there's a slider labeled Num Chunks. This, as the name suggests, controls how many pieces the static mesh in question will be cut up into. The more chunks, the more graphically intensive this fractured static mesh will be. There's also the matter of how you want it to break. For example, if you want a wall segment to break into larger chunks, then you would obviously want to pick a smaller number. The Fracture Tool dialog will appear as shown in the following screenshot:

The next setting we can use to control how our mesh breaks is labeled as Plane Bias and presents us with three ields with, by default, 1.0 in them. Plane Bias controls what direction the slices will be in. The three ields represent X, Y, and Z values, and if you were to put 0 in any two of them, the slices would all be completely perpendicular to the direction that still had a value. If we ind ourselves wondering what effect these numbers will have, we should play around with them and see. Every time we adjust one of the numbers, the generated slices will regenerate with the new settings applied.

[ 85 ]

Physics

The next important group of settings is the Chunk Options. These settings apply to individual chunks and, as such, the chunks we want to change must be selected. To select a chunk, we must left-click on it in the mesh preview window. To select multiple chunks, we simply have to hold the Ctrl key and left-click on additional chunks. If we look a little lower in our window, we'll see a row of buttons labeled as Chunk Selection. Here we have access to speciic shortcuts to select speciic groups of chunks: •

Grow Selection will select any unselected chunks adjacent to any that are already selected. If we click on it enough times, we'll ind that we have all of them selected.



Shrink Selection behaves in a similar way to Grow Selection, except it instead deselects any selected chunks adjacent to any that are already unselected. It should be noted that Grow Selection and Shrink Selection won't do anything if either all or none of the chunks are selected.



Select Top selects all of the chunks that make up the top edge of the original mesh shape.



Select Bottom, likewise, selects all of the chunks that make up the bottom edge of the original mesh shape.



Invert Selection basically selects any unselected chunks and deselects any that are selected.

These buttons are useful particularly when dealing with meshes with a large number of chunks. Once we've selected some chunks, we can adjust the settings in the Chunk Options section. There are three checkboxes in this section that we can toggle: •

The Destroyable option is exactly what it sounds like. Any chunks with this option checked can be destroyed and broken off of the mesh. Any chunks with this option unchecked cannot be destroyed. This is handy for situations where perhaps we want a wall segment to have a hole able to be punched in it but not be completely demolished.



The Support Chunk option labels a selected chunk as a support chunk, which sounds obvious. Basically, as long as a chunk is connected to a support chunk, it will remain stationary unless it is individually hit by something. Usually, support chunks are chunks that are adjacent to the edges of the mesh. In the case of an individual wall segment, this usually means the bottom edge.

[ 86 ]

Chapter 7



Finally, the Spawn No Physics option basically keeps any affected chunks from breaking off and spawning the broken pieces of the mesh that they usually do.

There are some other options available for adjusting fractured static meshes, but they are for generally esoteric cases, such as adding a core to the middle of a mesh to give the appearance of an underlying structure, and are therefore not within the scope of this book. As always, it is strongly encouraged that these tools be played around with to help in grasping their full potential.

[ 87 ]

Physics

When a fractured static mesh is generated, it, by default, does not have a material applied to the new faces that had to be created to represent the interior; that is to say, areas that aren't part of the initial mesh geometry. Breaking apart a newly created fractured static mesh will show off an interior of the default UDK blue and white checkerboards. Obviously we don't want this (except in very speciic situations, one would think). To assign a material to the interior bits, we'll simply search for a material in the search bar of the Unreal Static Mesh Editor. This will return two ields titled Material. The irst is the actual material applied to the original mesh. The second, at this point, should be blank. This is where we'll assign a material for the interior faces of our newly created fractured static mesh chunks. In most cases, simply applying the same material in both ields works well enough. It may have been noticed that, as things are, if we try to walk through a hole created in a fractured static mesh, it won't let us. Even if we completely destroy it, the collision of the original mesh remains. To ix this, search for "use simple" in the search bar of the Unreal Static Mesh Editor and uncheck the options for Use Simple Box Collision and Use Simple Line Collision. Problem solved; it is worth noting that although this approach may get us the behavior we want, it carries with it some added complexity which may, if used too liberally, cause performance to suffer.

Basic physics actors Basic physics actors are generally small objects littering a game world that can be moved through simple interactions. Sometimes as simple as running into them, you'll see boxes, barrels, pots, and other small detail pieces that it this description. Usually they aren't imperative to any element of gameplay, apart from the occasional stacking puzzle, but they always add a certain amount of realism to an environment. If someone sees a barrel and tells their game character to run over and hit it, they would rightfully expect said barrel to move. These actors are extremely easy to create. Basically, we'll just select whichever static mesh we wish to use, right-click where we want to place it and select Add Rigid Body: the name of our selected mesh. Voila, now we have a basic physics actor in our map.

[ 88 ]

Chapter 7

If our map is running in a UT game type, we are given a physics gun in our inventory. This item allows us to interact in fun ways with our basic physics actors. Left-clicking ires an impulse, which in effect punches any rigid body actors in range. Right-clicking and holding on a basic physics actor will pick up said actor, dropping it when we release the right mouse button. With some coordination, we can ling our basic physics actors all over the place. To access the physics gun, we simply start our game in the Play In Editor mode and scroll once using our mouse wheel. There is no visual cue of the physics gun in the player's hands, since it is not generally used in inal gameplay.

There are a few settings within rigid body actors that are notable. If we open up the properties for one of our placed basic physics actors, we'll ind all of the ones that concern us in the KActor and Stay Upright Spring categories: •

Under KActor we have the following: °

° ° ° •

Damage Applies Impulse basically states that if it is hit by something that causes damage, it should act as though it were hit by a force Wake on Level Start puts the object in active physics mode as soon as the level starts (normally we'd have to bump it with something first) Limit Max Physics Velocity limits the maximum velocity at which the object can move when it is being moved by physics Max Physics Velocity sets the actual maximum velocity

Under the Stay Upright Spring section, we have the ability to control how much an object wishes to stay upright when it is pushed by a physical force. By default, this behavior is turned off. °

°

Enable Stay Upright Spring turns it on Stay Upright Torque Factor and Stay Upright Max Torque adjust how hard it is to topple the object and how hard it tries to correct itself when it is being controlled by physics

[ 89 ]

Physics

Complex physics actors/ragdolls Ragdolls are very complex physics actors and, as such are a pain to set up correctly. Basically, the way ragdolls work is, they take a skeletal mesh and assign the entire skeleton as a sequence of rigid bodies connected by a constraint that acts like a joint. The reason this is so annoying and time consuming to set up properly is that, upon initial generation, all the settings regarding how much mass the bones should have, how springy they should be, and the range of motion of the joints are all set to allow as much freedom of movement as possible and, when allowed to try to simulate physics in that state, the results can be, well, interesting. An example of ragdolls is shown in the following screenshot:

That monstrosity is what happens when you generate a ragdoll from the default player mesh that we've seen. Clearly that isn't what we want. To create a default ragdoll: 1. Choose a skeletal mesh from the editor. 2. Right-click on it and select Create New Physics Asset. 3. We'll be met with our usual widget for asking where we want to place our new thing and what we want to name it. Fill this out and click on OK. 4. We're then met with a new widget asking us about what settings we want to use to generate the initial physics asset.

[ 90 ]

Chapter 7

If we're making a character ragdoll, we'll probably want to use Sphyl/Sphere collision geometry and have Walk Past Small Bones checked. Apart from that, and in some cases including that, it's really a matter of guess and test to see what gives us the best results for whatever we're making into a physics asset. With complex skeletal meshes like characters, however, it's nearly guaranteed that we'll have to do some adjusting in the PhAT (Physics Asset Tool) editor. To get there, either double-click on a physics asset in the Content Browser tab or, when creating a new physics asset, make sure to leave the Open In PhAT Now box checked. From there, clicking on OK will open up the PhAT Editor.

Now that we've opened up the PhAT Editor, we'll be presented with a screen that looks like this:

[ 91 ]

Physics

Basic use of this editor boils down to two primary keys. B will toggle between simulation mode, which lets us play around with our ragdoll and see how it simulates, and the editing mode, which lets us ix up our ragdoll by adjusting settings on its joints. S will, when in simulation mode, toggle the simulation on and off. When in simulation mode, we can change the weight of a bone by selecting the bone and adjusting the Mass Scale property. This is useful if when watching the simulation, we notice that parts of our ragdoll look like they're way too light or heavy. With a bone selected, pressing C will copy that bone's settings onto the next bone we click on. This makes spreading one bone's settings across an entire skeletal mesh much quicker.

In editing mode, we can adjust some helpful values on the joints. Primarily, we should work on adjusting the settings for Twist and Swing Limiting. In most cases, the checkboxes enabling these limiters should be checked. This allows us to control how much a joint will twist or swing before stopping.

If we have a joint set up in such a way that we want all of our joints setup that way, then we simply need to select our correct joint and click on Tools in the upper menu bar of the PhAT window and then select Copy Joint Settings to All Joints.

Setting up a proper ragdoll can be a very time consuming and frustrating process. Whenever we get stuck on something like this, it's best to look at an example. In this example, UDK has a physics asset already set up for our character's skeletal mesh, and it's located at PhysicsAsset'CH_AnimCorrupt.Mesh.SK_CH_Corrupt_Male_ Physics'. That is to say, it's located in the Mesh subpackage of the package named CH_AnimCorrupt. If we look at how this one is set up, it will help point us in the right direction regarding our own.

Other physics actors Now that we've covered the actors that can be affected by physics, let's talk about those that can apply physics. UDK gives us a number of ways to apply forces and impulses, and these forces and impulses can move many if not all of the objects we've covered so far in this chapter.

[ 92 ]

Chapter 7

Physics Volume Possibly the most versatile and useful of the bunch is the Physics Volume. It is placed in the world the same way as any other volume, and it comes with a rather large number of speciic settings to have it do a lot of things. The Physics Volume dialog appears as shown in the following screenshot:

[ 93 ]

Physics

Pretty much all of these settings are exactly what they sound like, so we're not going to go into them in depth. Sufice to say, Physics Volume can be used to make invisible lifts, gravity wells, simulated slick or sticky spots, and other such effects. If there are any settings that aren't clear, hovering over their name will generally pop up some text that will clear it up.

Force and Impulse actors On top of Physics Volumes, there is a pretty good list of other actors that can impart physics-based effects to our game world. To ind these, we simply need to go to the Actor Classes tab, which can be found next to the Content Browser tab, and expand the Physics subcategory, as shown in the following screenshot:

[ 94 ]

Chapter 7

Again, a lot of these are pretty self-explanatory, but the primary types we'll ind are Force Fields, which is a deined area where we can set up some more varied behaviors than that available to us from Physics Volumes, Constraint Actors, such as Hinges, Joints, and Pulleys, which behave exactly how their names would indicate when attached to rigid body actors, and Force and Impulse actors, which also behave precisely how their names indicate. Force and Impulse actors are very useful for simulating effects such as a shockwave from an explosion so long as they are properly triggered, usually in Kismet using a Toggle. These actors are fairly straightforward to set up and use, so we won't go on a hand-holding example for them. Instead, as always, it is recommended to just try things out and discover what they do. It really is the best way to learn once awareness of a tool has been granted. If you're looking for inspiration of things you can do using UDK for physics, there is a series of videos on YouTube that may be helpful: http://www.youtube.com/watch?v=40yJ84u6FL0& list=SP2700577862B92FD0

Summary Now that we have the ability to wreak havoc in our level with physics actors, we're going to step away from what we can see and focus on what we hear. It is arguably just as important for sounds to be done well when making a game, even if no one really talks about it much. In the next chapter we're going to cover how to set up sound effects in our game. We'll set up ambient sounds in our level as well as global sounds. We'll also take an in-depth look at the Sound Cue Editor, which lets us bend sounds to our whim without having to go back and forth between other audio editing software.

[ 95 ]

Sounds Now that we know how to make a playable game and have physics objects lying around, adding to the chaos, we should take a step back and look at a part of great games that is often overlooked. Games get judged heavily on the visuals they present, and well they should be. In all honesty, most games could be played with the sound off. That being said, if the goal is to create an environment that feels like it's an actual, true, and living environment, then we need to make sure that our ambient sounds are itting to our environment. If we want our game to have a cinematic feel, we need to make sure the music its what's going on. Sound in games is one of the unsung heroes. If it is doing it's job and setting the tone then you'll never hear about it. We'll generally only hear about the sounds in a game if they are not that good. Sometimes, albeit rarely, a game will use sounds to such great effect that it is almost, in itself, a part of the key mechanics of the game whether it's meant to be or not. In the Unreal Development Kit, sound effects can be created, controlled, and called to be played from any situation a game would need them to be. Whether that be an in level ambient sound, the sound a gun makes when it ires, the background music, or something as small as footsteps. So without further ado, let's take a look at how to make and use sounds in UDK.

Sounds

Sound cues versus sound wave data There are two types of sound entries in UDK: •

Sound cues



Sound wave data

The simplest difference between the two is that Sound Wave Data is what we would have if we imported a sound ile into the editor, and a Sound Cue is taking a sound wave data or multiple sound wave datas and manipulating them or combining them using a fairly robust and powerful toolset that UDK gives us in their Sound Cue Editor. In terms of uses, sound wave datas are primarily only used as parts of sound cues. However, in terms of placing ambient sounds, that is, sounds that are just sort of always playing in the background, sound wave datas and sound cues offer different situations where each is used. Regardless, they both get represented in the level as Sound Actors, of which there are several types as shown in the following screenshot:

Types of sound actors A key element of any well designed level is ambient sound effects. This requires placing sound actors into the world. Some of these actors use sound wave data and others use sound cues. There are strengths, weaknesses, and speciic use cases for all of them, so we'll touch on those presently. [ 98 ]

Chapter 8

Using sound cues There are two distinct types of sound actors that call for the use of sound cues speciically. The strength of using sound cues for ambient sounds is that the different sounds can be manipulated in a wider variety of ways. Generally, this isn't necessary as most ambient sounds are some looping sound used to add sound to things like torches, rippling streams, a subtle blowing wind, or other such environmental instances. The two types of sound actors that use sound cues are Ambient Sounds and Ambient Sound Movables as shown in the following screenshot:

Ambient sound As the name suggests, this is a standard ambient sound. It stays exactly where you place it and cannot be moved. These ambient sound actors are generally used for stationary sounds that need some level of randomization or some other form of speciic control of multiple sound wave datas.

Ambient sound movable Functionally very similar to the regular ambient sound, this variation can, as the name suggests, be moved. That means, this sort of ambient sound actor should be used in a situation where an ambient sound would be used, but needs to be mobile. [ 99 ]

Sounds

The main weakness of the two ambient sound actors that utilize sound cues is that each one you place in a level is identically set to the exact settings within the sound cue. Conversely, ambient sound actors utilizing sound wave datas can be set up on an instance by instance basis. What this means is explained with the help of an example. Lets say we have two ires in our game. One is a small torch, and the other is a roaring bonire. If we feel that using the same sound for each is what we want to do, then we can place both the ambient sound actors utilizing sound wave datas and adjust some settings within the actor to make sure that the bonire is louder and/or lower pitched. If we wanted this type of variation using sound cues, we would have to make separate sound cues.

Using sound wave data There are four types of ambient sound actors that utilize sound wave datas directly as opposed to housed within sound cues. As previously mentioned, the purpose of using ambient sound actors that use sound wave data is to avoid having to create multiple sound cues with only minimally different contents for simple ambient sounds. This is most readily displayed by the fact that the most commonly used ambient sound actors that use sound wave data are called AmbientSoundSimple and AmbientSoundSimpleToggleable as shown in the following screenshot:

[ 100 ]

Chapter 8

Ambient sound simple Ambient sound simple is, as the name suggests, the simplest of ambient sound actors. They are only used when we need one sound wave data or multiple sound wave datas to just repeat on a loop over and over again. Fortunately, most ambient sounds in a level it this description. In most cases, if we were to go through a level and do an ambient sound pass, all we would need to use are ambient sound simples.

Ambient sound non loop Ambient sound non loop are pretty much the same, functionally, as ambient sound simples. The only difference is, as the name suggests, they don't loop. They will play whatever sound wave data(s) that are set in the actor, then delay by a number of seconds that is also set within the actor, and then go through it again. This is useful when we want to have a sound play somewhat intermittently, but not be on a regular loop.

Ambient sound non looping toggleable Ambient sound non looping toggleable are, for all intents and purposes, the same as the regular ambient sound non loop actors, but they are toggleable. This means, put simply, that they can be turned on and off at will using Kismet. This would obviously be useful if we needed one of these intermittent sounds to play only when certain things happened irst.

Ambient sound simple toggleable Ambient sound simple toggleable are basically the same as a plain old, run of the mill ambient sound simple with the difference being, as like the ambient sound non looping toggleable, it can be turned on and off using Kismet.

[ 101 ]

Sounds

Playing sounds in Kismet There are several different ways to play different kinds of sounds using Kismet. Firstly, if we are using a toggleable ambient sound actor, then we can simply use a toggle sequence, which can be found under New Action | Toggle. There is also a Play Sound sequence located in New Action | Sound | Play Sound. Both of these are relatively straightforward in terms of where to plug in the sound cue.

Playing sounds in Matinee If we need a sound to play as part of a Matinee sequence, the Matinee tool gives us the ability to trigger the sound in question. If we have a Matinee sequence that contains a Director track, then we need to simply right-click and select Add New Sound Track. From here, we just need to have the sound cue we want to use selected in the Content Browser, and then, with the Sound Track selected in the active Matinee window, we simply place the time marker where we want the sound to play and press Enter. This will place a keyframe that will trigger our sound to play, easy as pie. The Matinee tool dialog will look like the following screenshot:

[ 102 ]

Chapter 8

Matinee will only play one sound in a sound track at a time, so if we place multiple sounds and they overlap, they won't play simultaneously. Fortunately, we can have as many separate sound tracks as we need. So if we ind ourselves setting up a Matinee and two or more sounds overlap in our sound track, we can just add a second one and move some of our sounds in to it.

Now that we've gone over the different ways to directly play and use sound cues, let's look at how to make and manipulate the same sound cues using UDK's surprisingly robust Sound Cue Editor.

Sound Cue Editor The Sound Cue Editor is a tool available within UDK that allows us to take sound wave data and shape it into what we want to use in our game. Within the Sound Cue Editor, we have the ability to apply Attenuation, Modulation, Randomization, Loops, Delays, and more to our sounds. We can access the Sound Cue Editor by right-clicking on a sound cue in the Content Browser tab and selecting Edit Using Sound Cue Editor.

[ 103 ]

Sounds

The Sound Cue Editor dialog will look like the following screenshot:

When irst entering a clean window of the Sound Cue Editor, all we see is one initial node that has some universally required settings. While there are other settings, there are only three that we are concerned with. These are the following: •

Volume Multiplier



Pitch Multiplier



Max Concurrent Play Count

All of these settings are pretty straightforward. The Volume and Pitch Multipliers affect the volume and pitch of any sounds plugged into this sound cue universally as a strictly multiplicative modiication. That is to say, if we set either of these numbers to 0.5, it will either be half as loud or played at half speed, which is the simple way many audio programs lower pitch. It can be used to create effect to relay slow motion sequences audibly. The Max Concurrent Play Count is the number of instances that this particular sound cue can be playing at the same time. If this is set to, say, 1, but the sound cue gets called from two different places in quick succession, then the game will simply just not play the second one.

[ 104 ]

Chapter 8

Now the simplest of sound cues would just be one that plays the selected sound so that everyone in the game can hear it. This is generally for things like announcements in multiplayer games or background music or something similar. To create this sort of sound cue, we need to only select the sound wave data we wish to use in the Content Browser, right-click in the open space of the Sound Cue Editor, and select the option that says Sound Node Wave:[Insert Name of The Sound Node We Have Selected Here]. We can also bring in multiple sound wave datas simultaneously by selecting all of the sound wave datas we want in the Content Browser and following the same steps.

The various nodes available in the Sound Cue Editor are as follows: •

Attenuation: Now, obviously, it's only in very rare instances that we'd want to have a sound play at full volume for everyone in the game to hear. Most sounds, particularly ambient sounds in the environment should behave similarly to sounds in the real world. That is to say, they'll sound quieter as the person hearing it gets further away. This effect is called attenuation, and there is a speciic node to control that in the Sound Cue Editor. The only settings of concern within the Attenuation node are those of Radius Min and Radius Max. All the other settings are generally just ine left at their default settings. The way the Attenuation node works is that if the player is within the Radius Min distance from the sound node, then the sound will play at full volume. As they exit the sphere created using Radius Min, the volume at which they hear the sound will decrease gradually as long as they are still within the sphere created using the Radius Max. Once the player exits that Radius Max bubble, then the sound will no longer play for them. Pretty straightforward really.



Concatenator: Another useful node based upon situations in the Sound Cue Editor is the Concatenator node. It has a fairly simple function. If we want two sounds to play one right after the other, we simply plug the irst sound wave data into the top connector and the second sound wave data into the bottom connector. The only settings within the node are the ability to control the volume of each sound wave data independently with volume multipliers.



Delay: Next, we have the Delay node. It, simply inserts a delay into our sound cue. Generally, this is mostly used when we have several sound wave datas that we want to play, just not all at once or one after the other. In the Delay node, we can set a Delay Min and Delay Max. If these two numbers are different, then the delay will choose a value randomly between the two to use as the delay. If we, however, simply want to set a speciic delay, then we simply set both of these values to that number. [ 105 ]

Sounds



Looping: The Looping node will, as the name suggests, take anything plugged in after it and loop it over and over again. There is a checkbox option for Loop Indeinitely that, when checked, will repeat the loop, well, indeinitely. Below that there are values for Loop Count Min and Loop Count Max. Similar to the Delay Min and Delay Max values mentioned previously, if these numbers are different then the node will pick a number between them at random. If the numbers are the same, then it will loop that many times.



Mixer: The Mixer node will take multiple sound wave datas that can also be combined with delays and effects and play those sequences simultaneously. By default, it only starts with two inputs, but we can add inputs by rightclicking on the node and selecting Add Input. Within the node, there are options to give each input a different volume multiplier, which can allow us to weight some sounds to be more prevalent than others.



Modulator: The Modulator is a handy node as well. Quite simply, it allows us to control the pitch and volume of whatever comes after it. Similar to the multipliers in the base node, but we can put it anywhere, so if we need one sound wave data to have a lower pitch than another, we can treat them individually. The pitch and volume multipliers come with a Min and Max, which behave like all of the other min and max pairs we've encountered. If we set two numbers, this node will pick a value between them randomly.



Continuous Modulator: Possibly one of the most powerful nodes in the Sound Cue Editor, the Continuous Modulator node offers us some interesting capabilities. If we have a sound wave data that is just too long, we can tell it's volume to drop to zero at a set time. Likewise, if we wanted to have the pitch go up and down to certain points at certain times, we could set that up however we'd like. The key to learning how to fully utilize and control this node is all about the Distribution sections under Pitch Modulation and Volume Modulation as shown in the following screenshot:

[ 106 ]

Chapter 8

While there are seven different options to choose from, there are only three we're going to cover: •

DistributionFloatConstant option allows us to pick one number and have that be the pitch or volume multiplier for the entire duration of whatever comes after this node in the sound cue



DistributionFloatConstantCurve, which is the default selection, will constantly luctuate between the min and max values you set, which creates a sort of strange set of effects



DistributionFloatUniform option, however, lets us basically set points not terribly different from key frames in a Matinee sequence to create a graph that the sound cue will follow in terms of volume and pitch

The following screenshot shows the options explained in the preceding section:

We can add as many points as we need, and the primary controlling values are In Val, which is at what time we want the volume or pitch to hit the value given by using the multiplier set into Out Val. For example, if we wanted to create a slowing to super slow motion sound, we would want it to start at its regular pitch, and then drop drastically over a couple seconds. This would require two points to be speciied in the Pitch Modulation | Distribution | Constant Curve | Points array. The irst point would have an In Val, or time, of 0, and an Out Val, or multiplier, of 1.0. This would mean that, starting at the 0.0 second mark of the sound cue sequence following the continuous modulator, the pitch would be at a 1.0 multiplier. If we wanted the slow down effect to inish at, say, two seconds, then our second point would want to have an in val of 2.0 and an out val of something lower than 0.5. Now the pitch of whatever we have plugged in after the continuous modulator node will start at a multiplier of 1.0 and, over the course of 2 seconds it will gradually decrease to 0.5 or whatever we set in our second point. There are numerous uses for this node, but it is not as obvious as to how to use it as the others. [ 107 ]

Sounds

Random: Finally we have the Random node. This node allows us to plug in as many sound wave datas or sequences as we'd like, similar to the Mix node. The difference is that instead of playing all of them at once, it selects one at random. Within the node itself, instead of the volume multipliers of the Mix node, the Random node has Weights. This allows us to give certain entries a better chance of being selected than others. For example, for two entries with the same weight, say 1.0, there's an equally likely chance of which one it will chose. If, for example, one was set to 1.0 and one was set to 0.5, then it would be twice as likely that the one weighted 1.0 would be chosen.

Summary Now that we have a decent grasp of what kinds of sound control UDK offers us and how to manipulate sounds in the editor, we can set about bringing our game to audible life. A quick tip for placing ambient sounds: if you look at something that visually seems like it should be making a noise like a waterfall, a ire, a lickering light, or whatever else, then it probably should have an ambient sound of some sort placed right on it. And as always, what we've covered in this chapter is an overview of some of the bare bones basics required to get started exploring sounds and soundscapes in UDK. There are plenty of other actors, settings, and things that can be done. So, again, I recommend playing around with anything you can ind. Experiment with everything in UDK and you'll learn all sorts of new and interesting things. In the next chapter, we'll be taking a quick look at a system that I myself am only moderately versed in and everything I learned about it was pretty much entirely learned from playing around. This system is the Material system. We'll be covering how to apply and manipulate materials as well as how to edit them in the Material Editor.

[ 108 ]

Materials Now we're getting pretty close to having a completed game prototype, so we're going to sort of cool down and take a quick look at some more specialized systems offered by UDK. In this chapter, we're going to be looking at materials. Materials are basically what go on all sorts of objects to keep them from just having the blue and white checkerboards that we've seen. They can relay texture, relectiveness, varying levels of opacity, and other effects by combining textures in the Material Editor. The difference between textures and materials is similar to the difference between sound wave datas and sound cues. That is to say, just as taking sound wave datas, combining them, and adding effects to them in the Sound Cue Editor creates sound cues, similarly taking texture iles, combining them, and adding effects in the Material Editor creates materials.

Materials

We're only going to take a quick glance at the tools and systems concerning materials due to the fact that this book covers more technical aspects of making games using UDK.

Importing a texture If we want to make a new material, either basic or complex, we're going to need at least one texture. If that texture is not the one already present in UDK, then we need to import it. To successfully accomplish this is fairly simple, but requires some speciic things. First, the image should be in a format supported by UDK. I recommend Targa or .tga. This recommendation is based purely on Targa being the most common that I've encountered. UDK also supports .bmp, .png, and several other formats as well. Second, it should be perfectly square and have a side measurement that is a power of two pixel count. That is to say, 64 x 64, 256 x 256, 1024 x 1024, and so on. Generally, the larger space we plan on using the material on that utilizes any given texture, the bigger that texture should be. But we need to be careful, because if we start bringing in dozens of 2048 x 2048 textures, it's going to decimate our frame rate very quickly. Once we have our Targa ile sized correctly, it's very simple to bring it into UDK. First, we simply right-click on the Content Browser tab and select Import.... Then we navigate to the Targa ile or iles we want to use, select them, and click on OK. We will then be presented by the familiar widget that appears whenever we're moving, copying, or adding something to a package. We need to ill out the basic information and then press OK. This will add the Targa to whichever package we specify.

Material Editor The real meat and potatoes of making materials is, of course, the Material Editor. Material Editor when paired with a talented artist or art team is a ridiculously powerful tool for making things look awesome in UDK. The Material Editor has the power to make lat objects look like they have some level of depth, make static objects appear to have some sort of motion, and even tell the sun where in the sky it should be. If we take a look at some materials that come in standard UDK, we can quickly see that working with materials can be an involved and complex process. So, what we're going to do in this chapter is look at maneuvering in the Material Editor and then go over some of the basic functions and features that the Material Editor has to offer. Then we're going to take what we've learned, apply the investigate, and play around with the attitude we've used throughout this book to discover what other secrets we can unlock within this powerful tool.

[ 110 ]

Chapter 9

To open the Material Editor, we simply need to double-click on any material in the Content Browser tab. We would do well, eventually, to use examples provided to us by default within UDK. For now, however, we will make a brand new material by right-clicking on the Content Browser tab and selecting New Material or by right-clicking on a texture we wish to use and selecting Create New Material. The Material Editor page will look like the following screenshot:

Maneuvering within the Material Editor is pretty much identical to maneuvering within the Kismet environment. Right-clicking on it brings up a list, similar to the list of different things we can place in Kismet which will allow us to select all of the different nodes that we can use in the Material Editor. Using these nodes as building blocks, materials can turn into extremely complicated creations, as illustrated in the preceding screenshot, which is of the material used on the sky dome in the default level templates. While we're going to cover a fair number of some of the most commonly used nodes within the Material Editor, it would be a smart idea to look at how some of the materials that come with UDK are set up and experiment using those materials as examples. But for now let us go over some of the more commonly used types of nodes and their functionality.

[ 111 ]

Materials

There are many different nodes available to us in the Material Editor. Possibly the most important of these is the root node that would be the only one present if we made and opened up a brand new material. This is the node all the other nodes must plug into in order to have any bearing on the material as a whole. The root node has many different points at which we can connect things, but for our purposes there are only a handful that we are going to look at. These are the Diffuse, Emissive, Specular, Opacity, and Normal connectors. They are pretty standard in terms of being used, and it's good to know what they do and are explained as follows: •

The Diffuse connector is the groundwork for a material's function in so far, as it represents where the application of basic coloring will be handled. In all honesty this is probably one connector that should nearly always have something plugged into it. There are likely situational examples where this is not the case, but for the purposes of a quick understanding of the toolset, these situations shall not be prevalent.



The Emissive connector controls areas that should generally emit some sort of light. This manifests itself generally in terms of a glow.



The Specular connector generally controls how shiny a material appears to be.



The Opacity connector is by default grayed out, as speciic properties need to be set properly for this to be usable. But when it is a functional connector, what is plugged in there controls how visible or invisible the parts of the material are.



The Normal connector controls something called normal mapping. A normal map is a way to use a speciically generated type of texture, such as fake lighting on bumps and dents, without the need to have them meticulously modeled. For example, if we were making a canvas or leather material and there were all those little bumps, grains, and creases that leather or canvas tend to have, we wouldn't want all those little details to be modeled, but we'd still wish them to be visible. This would be done using normal maps.

[ 112 ]

Chapter 9

The various connectors are shown in the following screenshot:

Also, within the root node there are a plethora of preferences, but for the introduction to the tool only a couple of them are worth mentioning. First is the Blend Mode setting, which is by default set to BLEND_Opaque, but must be set to BLEND_Translucent to activate the Opacity connector. Second is the two-sided checkbox. This should be set to true if we are using a plane object somewhere that can be viewed from two sides. For example, if we were making a leaf or an object that had leaves on it, then we wouldn't be using a thin 3D model. Instead, we'd use a perfectly lat plane. The problem is, if we apply a default material, it would only apply to one side and not render the other, making the leaf seem to disappear if the player walked around it. If the two-sided checkbox is checked, then it will apply the material to both sides of the leaf in question. As far as nodes that need to be added are concerned, there are many, but this book doesn't have the scope nor the author expertise to cover all of them. We will cover a fair number of some of the more commonly used ones, going down the list in the preceding screenshot.

[ 113 ]

Materials

Constants Within the Constants section, we have a few different nodes of interest, but all of them basically behave the same. It's just a matter of the type of constant they are. There is New Constant which is just a numerical value. There's also New Constant2Vectors, New Constant3Vectors, and New Constant4Vectors, which basically behave similar to the regular Constants, but in the form of vectors with 2, 3, and 4 components respectively. Finally there's New VertexColor which behaves similar to a vector with 4 components, but this special node has 4 outputs for the Red, Green, Blue, and Alpha channels. The Alpha channel controls opacity.

Coordinates The Coordinates section contains two nodes that we'll concern ourselves with. These are the New Panner and New Rotator nodes. They take in a set of coordinates, usually represented by a texture reference, and a time node and pair them with their node-speciic properties to either laterally move a texture in the case of the panner or rotate a texture in the case of the rotator.

Math The Math section of nodes has a lot of handy operational nodes that are generally very straightforward, including New Add, New Divide, New Multiply, and New Subtract. They each take two values and do exactly what their names say they do, outputting the result. Some of the other ones might be a little less clear. New Abs brings back the absolute value of what is plugged into it, New Ceil boosts everything to a ceiling value which, in terms of colors, means white, and New Floor does the opposite and brings everything down towards black. New OneMinus will output whatever goes into it subtracted from 1, New Power will take a Base and Exponent value and return the Base to the power of the Exponent, and New SquareRoot will return the square root of what is plugged into it.

[ 114 ]

Chapter 9

Parameter The Parameter section of nodes is used when a material is being made so as to be used in Material Instance Constants. Within this section of nodes, there are only two with which we need concern ourselves. These are New ScalarParameter and New VectorParameter. These operate exactly the same as the regular New Constant and New VertexColor, except that they represent editable values within the Material Instance Constant to be created. Material Instance Constants are used when we wish to use slightly varied versions of materials and don't wish to make brand new materials for each version. They are created by right-clicking on the Content Browser tab and selecting New Material Instance Constant. Then, within the properties of the said Material Instance Constant, you set the parent property to the base material and then any parameters that are set up inside the parent will pop up as editable properties in the Material Instance Constant.

Texture There is truly only one node necessary to know in the Texture category: New TextureSample. It can be set to contain the data of any texture and, therefore, is required to really do anything of much note or importance in a material.

WorldPosOffset Similar to the Texture category, there is only one node to know in this category, and that is the New Time node. This is needed to be plugged into a panner or rotator to get it to function properly. It represents a constantly incrementing variable that tells these sorts of nodes to change values. This pretty much covers the Material Editor. The only other thing that we'll mention here is while working in the Editor, to save any changes we've made and to see any updates in the preview pane, we must click on the green check mark in the upperleft of the page.

[ 115 ]

Materials

Decal materials Decals are a very speciic type of actor. Basically, they work as their name would suggest. That is to say that when placed, they apply a lat sort of sticker to whichever object they are placed on. Apart from that, they are made and edited almost identically like regular materials. To make a new decal material, simply right-click on the Content Browser tab and select New DecalMaterial and voila, so long as we don't mess around with the root node properties too much, we've got a material that can be used as a decal.

Summary Now that we have a basic understanding of the Material Editor and how to maneuver and edit materials within it, we can go and mess around with some of the default ones included within UDK. In the next chapter we'll be covering how to do things within the Animation Set Viewer tool. This includes setting up events, called notiies, that can be triggered by animations.

[ 116 ]

Characters and Animation You may have noticed that there are a number of things the in-game playable character just does on its own. Sound effects or particle effects play an important role when the character in the game is hurt, dies, or just steps forward. You may have also noticed that it knows to keep our character in certain animations depending on what state we're in. For example, it knows to play a run animation when we are running or a few jump animations when we're jumping or falling. This situational animation knowledge is admittedly more noticeable if it in fact is not working correctly, but you may have noticed it nonetheless. You may have seen, perhaps in other games, situations where characters animate during cutscenes or just idly in the world. In UDK, all of these effects are able to be set up and controlled by us, the developers, by utilizing tools found in the Anim Set Viewer, the Anim Tree Editor, Matinee, and preferences within Skeletal Meshes placed within a level. This chapter will cover the methods present in each of these tools to achieve these types of effects. It should be noted that the process for changing what Skeletal Mesh animations or Anim Tree are used, along with some speciic situational sounds, is controlled within the Player Pawn, which is in turn set within the Game Type. These things, particularly the Game Type, are somewhat complicated to change; more complicated than this book is going to cover.