Technicaldesigndocument
Technicaldesigndocument
Table of Contents
Introduction How to Read the Document UDK Online Documentation UDK Architecture Version Control Special Setup for our Project Packaging a Game UnrealScript Compiling a Script Setting up Development Environment Setting up nFringe Setting up Config File to Compile your Scripts Compiling Log Console Game Types GameInfo SimpleGame UTDeathMatch Why is Play on PC not using my custom controller/pawn? Objects Data Structures Math Functions Actors Important Functions simulated event PostBeginPlay() event Tick(float DeltaTime) CollidingActors(...) Example DefaultProperties Variables Working with Rotations Rotator Converting Values Between Unreal Units, Radians, Degrees Pawns How to Change Skeletal Mesh Easy Way Hard Way Controllers Why isnt Tick() working? Artificial Intelligence (Bots) Razer Hydras
Callback Functions Calibration How to Track Hydra Positions Our solution Hydra Units Oculus Rift Oculus Data Controlling the Rifts Orientation Why Cant I modify the Rifts Pitch? UDK Editor Setting up Editor for Oculus Rift Getting the 32-bit Editor Learning UDK Editor Video Tutorials* 3D Buzz Useful Hotkeys Navigating Perspective Viewport FPS Style Camera Movement Increasing/Decreasing Camera Movement Speed Strafing the Camera Moving the Camera Forwards/Backwards and Turning Kismet Sub-Sequences Useful Hotkeys Touch Triggers Why isnt my KActor hitting the trigger? Named Variables Matinee Grouping Actors in Viewport Manipulating Individual Actors in a Group Simplygon Cascade (Particle Editor) Builder Brushes (BSP) Geometry Mode Crash Warning!
Introduction
Welcome to the UDK Technical Design Document. Since Unreal already has the Unreal Development Network for technical documentation, this document will be going over the techniques we are using for our project, including working with the Oculus Rift and Razer Hydras.
UDK Architecture
UDK uses an Object-Oriented architecture. The user is expected to know what this means and how it works. Above the base code is the UnrealScript scripting language that UDK uses, which this document is focused on.
Version Control
For our project we will be using Mercurial SVN and the TortoiseHG GUI. TortoiseHG can be downloaded at: http://tortoisehg.bitbucket.org/download/index.html The game repository address for Team Odyssey is located at: https://hg.digipen.edu/projects/pathfinder
Packaging a Game
An online guide is located at:
http://www.hourences.com/an-entire-simple-udk-game/ Note: It is highly recommended to make a copy of all Default config files so that you can easily roll back changes in case you mess something up. Summary 1. If you just want to package a level to load by default and not a mod/game, then skip to Step 4 below. 2. Locate DefaultEngine.ini config file within \UDKGame\Config. 2.1. 2.2. 3. 3.1. Find [UnrealEd.EditorEngine] and add +ModEditPackages=<ModName> to the end of the list, where <ModName> is replaced by the name of your mod folder. Delete UDKEngine.ini so that UDK generates a new one with your changes. Find [Engine.GameInfo] so that you set up a default game info and controller. 3.1.1. If you have a custome game info, then 3.1.1.1. Replace DefaultGame=UDKBase.SimpleGame with DefaultGame=<ModName>.<ModGameInfo>. 3.1.2. If you have a custom player controller, then 3.1.2.1. Replace PlayerControllerClassName=UDKBase.SimplePC with PlayerControllerClassName=<ModName>.<ModPlayerController> 3.1.3. To create a custom map prefix if you have a custom game info, 3.1.3.1. Add +DefaultMapPrefixes=(Prefix=<ModAcronym>,bUsesCommonP ackages=FALSE,GameType=<ModName>.<ModGameInfo>). 3.1.4. Delete UDKGame.ini so that the engine will make a new one for you with your modifications. 4. If you have a custom level to load by default, then locate DefaultEngine.ini within \UDKGame\Config and go to section [URL]. 4.1. 4.2. 5. 5.1. 5.2. Change Map=UDKFrontEnd.udk to Map=<Name of your map>. Change LocalMap=UDKFrontEnd.udk to Map=<Name of your map>. When you load up Frontend, you should clear the list of maps to cook and add your own custom map(s). When you are ready to begin the cook process, click on Start. It should run through compiling your scripts, maps, and attempt to launch the game so that you can verify it works. Locate DefaultGame.ini within \UDKGame\Config.
Now you can cook your game using Unreal Frontend, which can be found in \Binaries\
5.2.1. If you dont want Frontend to automatically run your game during the Start cook sequence, you can disable it by clicking on the black arrow next to the Launch text to disable it. 5.3. After you have verified everything has cooked properly, you can then package the game by clicking on the Package Game button. 5.3.1. After packaging is done, you will find the installer in your root UDK folder.
UnrealScript
http://udn.epicgames.com/Three/UnrealScriptHome.html
Compiling a Script
There are a couple of ways to compile script, but each way has a preliminary setup.
Log Console
To enable the log console for debugging, you will need to add -log to the editors target as a parameter, so it should look something like this:
Game Types
http://udn.epicgames.com/Three/GametypeTechnicalGuide.html
GameInfo
This is also where you would want to start when making a mod from scratch. There are couple GameInfos you can extend off of to get your mod started: SimpleGame A generic GameInfo that will not handle re/spawning bots but will still spawn a default controller/pawn for the player. UTDeathMatch This GameInfo handles re/spawning players and bots in the game. It also has killspree announcements for players. it wll keep track of player kills and contains win/lose conditions related to time and kill counts. Why is Play on PC not using my custom controller/pawn? You will need to override the following function:
static event class<GameInfo> SetGameType(string MapName, string Options, string Portal) { return Default.Class; }
Putting this in your GameInfo that extends UTDeathMatch should override the SetGameType() function and use your default pawn/controller.
Objects
Every single UDK class is extend from the Object class or its children. Object contains many generic functions for math, which will be covered in a later section. Classes that extend off of Object are generally systems that maintain core technical systems such as animations and factories.
Data Structures
Object.uc contains lots of data structures used throughout the engine, the most important ones we will be using are Rotator and Vector.
Math Functions
Object.uc also contains all general math functionality related to vectors, trigonometry, interpolations, etc.
Actors
// Actor: The base class of all actors. // Actor is the base class of all gameplay objects. // A large number of properties, behaviors and interfaces are implemented in Actor, including: // // Display // Animation // Physics and world interaction // Making sounds // Networking properties // Actor creation and destruction // Actor iterator functions // Message broadcasting // // Copyright 1998-2013 Epic Games, Inc. All Rights Reserved.
Important Functions
simulated event PostBeginPlay() This is the initialization function that is triggered after the game has finished loading. event Tick(float DeltaTime) This is called every frame where DeltaTime is the time between the current frame and previous frame in seconds.
CollidingActors(...) This function is used to detect Actors within a radius of a location, and gets a reference to the actor. It generally used in iterations. Example { local Actor P; //You can use any other actor class and does not have to be Actor local Vector TempLoc; //This will iterate through every Actor class object within 128 Unreal Units //of the actor this is being called from and prints out their world location. foreach CollidingActor(classActor, P, 128); { `log(P.Location); } //This will iterate through every Actor class object within 128 Unreal Units //of the TempLoc. TempLoc is overriding where the detection should radiate from. foreach CollidingActor(classActor, P, 128, TempLoc); { `log(P.Location); } }
DefaultProperties
http://udn.epicgames.com/Three/UnrealScriptDefaultProperties.html Nearly all scripts will contain a DefaultProperties code block at the end of the script. This block is a focused section of the code to initialize values and to help non-programmers make modifications to values such as pawn health or speed.
Variables
http://udn.epicgames.com/Three/UnrealScriptVariables.html Unrealscript has their own way of declaring variables. The important keywords you should know are var and local. var is used for global declarations and local is used for declaring within the scope of a function. Unrealscript variables also follows the C-Style variable declarations in which variables must be declared at the beginning of the function and cannot be declared later.
Rotator
Rotator values range between [0, 65536].
Pawns
http://udn.epicgames.com/Three/CharactersTechnicalGuide.html
Hard Way The hard way takes advantage of UDKs FamilyInfo system, which we most likely will not be diving into. If you are curious, you may refer to this UDK Documentation page: http://udn.epicgames.com/Three/UDKCustomCharacters.html
Controllers
http://udn.epicgames.com/Three/CharactersTechnicalGuide.html
Razer Hydras
http://forums.epicgames.com/threads/937066-Razer-Hydra-Dll-Bind-Player-Input-and-PlayerController-Ready-to-go The Razer Hydras are hooked up into UDK using the scripts provided by Craig A. DeLancy. They handle and process raw input from the Razer Hydras.
Callback Functions
Razer Hydra button callbacks are located in the base Controller class provided by Craig A DeLancy.
Calibration
The Hydras need to be calibrated every time the game restarts by having the user point the Hydras towards the Hydra Base, then calling the function: sixenseAutoEnableHemisphereTracking( int HydraController ) from the RazerInput class, where HydraController = 0 is the left controller and 1 is the right controller. Warning: Failure to calibrate with the users pointing the Hydras at the Hydra Base may create undesirable results.
Oculus Rift
Oculus data can be referenced by adding the following lines of code to your function or class: local Oculus OC; OC = class'Oculus'.static.GetGlobals();
Oculus Data
You can access the Oculus current rotation by calling OC.Rotation. Rotation is a UDK Rotator, so it can return values ranging from [-65536, 65536].
UDK Editor
Setting up Editor for Oculus Rift
The current released version of the Oculus UDK we are using at this time (v0.1) does not support running Oculus code in Play in Editor and only works in Play on PC. It also will not work with the 64-bit version of the editor.
Video Tutorials*
http://udn.epicgames.com/Three/VideoTutorials.html 3D Buzz 3D Buzz has a series of videos to teach you how to use the Unreal Development Kit editor at: http://www.3dbuzz.com/training/view/unreal-development-kit *Note: These videos are a couple years old and some features may have been deprecated or moved around.
Useful Hotkeys
Show/Hide Builder Brush Push B Snap Actor(s) to Nearest Floor Select actor(s) and push the End key. Focus on Actor(s) Select actor(s) and push the Home key.
Kismet
http://udn.epicgames.com/Three/KismetHome.html http://udn.epicgames.com/Three/KismetExamples.html Kismet is UDKs powerful visual scripting editor within the UDK Editor.
Sub-Sequences
Kismet Sub-Sequences are a useful way to organize your space. Sub-Sequences can be created by right-clicking anywhere in the current Kismet window and clicking on Create new sequence. Sub-sequences are also automatically generated when making a prefab of an object that uses a kismet sequence.
Useful Hotkeys
Quick Comment Block Have object(s) selected and push C This will prompt you to input a comment and will then create a comment box around the objects you selected. Drag Box to select multiple objects Ctrl + Alt + Left-Click Drag This will allow you to drag a box around multiple nodes and variables to select at once. Focus on Selected Objects Push A with objects selected, otherwise this will zoom the camera out to encompass all objects in the sequence. Select Multiple Objects One at a Time Hold Ctrl and click on an object.
Touch Triggers
Why isnt my KActor hitting the trigger? To make a KActor toggle a trigger: 1. You will need to go into the KActors properties and set no encroach check to false. This will enable encroaching for the KActor which will stop it from being ignored by certain collision detections, one of which is detecting collision with the trigger. 2. In the trigger node within Kismet, you will need to make sure the Touch Types > Class Proximity Types lists the KActors class type or one of its parents. 3. Make sure Sequence Event > Player Only is set to false.
Named Variables
http://udn.epicgames.com/Three/KismetUserGuide.html#Named Variables Named variables are very useful in Kismet as they allow the user to reference variables without having to create a link to them.
Matinee
http://udn.epicgames.com/Three/MatineeAndCinematicsHome.html http://www.youtube.com/watch?v=HUtbKqWcPkI (Matinee UI Tutorial) Matinee is a powerful tool for keyframing objects in the game. It can be used to create cutscenes and animations, but can also control when particles/lights flicker on/off.
Simplygon
http://udn.epicgames.com/Three/MeshSimplificationTool.html Simplygon is a powerful tool to lower LOD of meshes. This is very handy for us since we are using a low resolution Oculus devkit.
Geometry Mode
http://udn.epicgames.com/Three/UsingBspBrushes.html Geometry mode is a useful editor mode that allows the user to modify faces and vertices of BSPs.
Crash Warning!
Build Brushes do not like to be undone (ctrl+zd). Be careful when undoing builder brush adjustments with Geometry Mode as it may crash the editor and cause you to lose all unsaved progress.