Introduction to the Unreal Development Kit

Preview:

DESCRIPTION

Introduction to the UDK from a programmer's perspective, featuring UnrealScript, navigation meshes, weapons system and networking.

Citation preview

Introduction to the Unreal Development Kit (UDK)

Nick Prühs

October 23, 2013

About Me

“Best Bachelor“ Computer ScienceKiel University, 2009

Master GamesHamburg University of Applied Sciences, 2011

Lead ProgrammerDaedalic Entertainment, 2011-2012

Co-Founderslash games, 2013

2 / 58

Features

• complete editing environment

• pure rendering power (Gemini)

• state-of-the-art animation(Mantinee)

• powerful scripting (Kismet)

• real worlds physics

• eye-popping lighting and shadows (Lightmass)

Features (Cont.)

• gorgeous cinematics (Mantinee)

• terrain

• built-in networking

• real-time shaders

• broad audio support

• particle effects (Cascade)

Features (Cont.)

• artificial intelligence

• distributed computing (Swarm)

• descructible environments

• Bink video codec

• SpeedTree foliage editor

• FaceFX facial animation

• Scaleform 4.0 UI

Platforms

Platforms

Platforms

Integrated Partners

Licensing

• non-commercial use:• free!

• commercial use:• USD 99 up-front

• 0% royalty on first USD 50,000 in UDK related revenue

• 25% royalty on UDK related revenue above USD 50,000

Useful Stuff

• UT Source Code

• UDK Forums

• Showcases

• UDK Programming Home

• UDK Gems

• UnrealScript Language Reference

Working With The UDK

• UDK vs. Licensees

• monthly releases• Feb 12: Recast

• May 12: RealD 3D

• Feb 13: Substance

• Visual Studio 2010 & nFringe

• UnrealEd & UnrealFrontend• Content Packages

Unreal Engine Basics

• Core• C++

• Rendering, Sound, GameLoop, Collision, Physics, Threading, Low Level Network

• Virtual Machine• runs in core

• executes UnrealScript

Unreal Engine Basics (Cont.)

• UnrealScript• similar to C++ and Java

• high-level object-oriented language

• pointerless environment with automatic garbage collection

• simple single-inheritance class graph

• strong compile-time type checking

• safe client-side execution "sandbox"

Class Hierarchy

UnrealScript Features

• instantiation• Actor.Spawn(class<Actor>) vs. new

• timers• Actor.SetTimer(float, bool, name)

• iterators• Actor.AllActors

• Actor.DynamicActors

• Actor.CollidingActors

UnrealScript Features (Cont.)

• statesstate Dead

{

ignores SeePlayer, HearNoise, KilledBy, NextWeapon, PrevWeapon;

function bool IsDead()

{

return true;

}

// ...

}

Source: PlayerController.uc

UnrealScript Features (Cont.)

• exec functions.Bindings=(Name="MouseScrollDown",Command="GBA_NextWeapon")

Source: DefaultInput.ini

UnrealScript Features (Cont.)

• exec functions.Bindings=(Name="MouseScrollDown",Command="GBA_NextWeapon")

Source: DefaultInput.ini

exec function NextWeapon()

{

if ( WorldInfo.Pauser!=None )

return;

if ( Pawn.Weapon == None )

{

SwitchToBestWeapon();

return;

}

if ( Pawn.InvManager != None )

Pawn.InvManager.NextWeapon();

}

Source: PlayerController.uc

UnrealScript Features (Cont.)

• config filesclass HWPawn extends HWSelectable

config(HostileWorldsUnitData)

abstract;

/** The value the damage of all attacks is reduces by before being applied. */

var config int Armor;

/** The ground movement speed of this unit, in UU/s. */

var config int MovementSpeed;

Source: HWPawn.uc

UnrealScript Features (Cont.)

• config filesclass HWPawn extends HWSelectable

config(HostileWorldsUnitData)

abstract;

/** The value the damage of all attacks is reduces by before being applied. */

var config int Armor;

/** The ground movement speed of this unit, in UU/s. */

var config int MovementSpeed;

Source: HWPawn.uc

[HostileWorlds.HWSM_Commander]

Armor=0

MovementSpeed=160

Source: UDKHostileWorldsUnitData.ini

UnrealScript Features (Cont.)

• localization filesclass HWAbility extends Actor

config(HostileWorldsAbilityData)

abstract;

/** The name of this ability. */

var localized string AbilityName;

Source: HWAbility.uc

UnrealScript Features (Cont.)

• localization filesclass HWAbility extends Actor

config(HostileWorldsAbilityData)

abstract;

/** The name of this ability. */

var localized string AbilityName;

Source: HWAbility.uc

[HWAb_Cloak]

AbilityName=Cloak

Source: HostileWorlds.int

UnrealScript Features (Cont.)

• meta data/** Enable or disable spawning. */

Var() bool bEnableSpawning;

/** Set the rate at which AIs are spawned. */

Var() float RespawnsPerSecond<EditCondition=bEnableSpawning>;

Source: http://udn.epicgames.com/Three/UnrealScriptMetadata.html

Navigation Meshes

• connected graph of convex polygons

• at each node we know that an AI can get from any point in that node, to any other point in that node due to its convexity

• thus the task of pathfinding through the graph simplifies into pathfinding along a connected graph of nodes• much more natural looking movement

Navigation Meshes (Cont.)

Source: http://udn.epicgames.com/Three/NavigationMeshReference.html

Navigation Meshes (Cont.)

Source: http://udn.epicgames.com/Three/NavigationMeshReference.html

Navigation Meshes (Cont.)

Source: http://udn.epicgames.com/Three/NavigationMeshReference.html

Obstacle Meshes

• represent obstacles in the world

• allow low-fidelity raycasts (against this obstacle mesh only) when an AI needs to know whether it can walk from one point to another directly

• allows us to skip doing a path search in wide open areas even if there are many polygons between the start and the goal

Navigation Meshes

DEMO

Benefits of Navigation Meshes

• can represent a large area with a single polygon• overall graph density goes down

• memory footprint reduced

• pathfinding time goes down

• less time fixing up cross-level pathing information

• better pathing behavior

• automatic generation

Benefits of Navigation Meshes (Cont.)

• handling of dynamic objects

Source: http://udn.epicgames.com/Three/NavigationMeshReference.html

Benefits of Navigation Meshes (Cont.)

• handling of dynamic objects

Source: http://udn.epicgames.com/Three/NavigationMeshReference.html

Weapons & Inventory

/** Holds the list of link guns linked to this weapon */

var array<UTWeap_LinkGun> LinkedList; // I made a funny Hahahahah :)

Source: UTWeap_LinkGun.uc

Weapon Fire

Weapon Fire (Cont.)

Weapon Fire (Cont.)

Weapon Fire (Cont.)

Weapon Fire (Cont.)

Weapon Fire (Cont.)

Weapon Fire (Cont.)

Weapon Fire (Cont.)

Weapon Fire (Cont.)

Weapon Fire (Cont.)

Weapon Fire (Cont.)

Weapon Fire (Cont.)

Network

“Unreal views the general problem of coordinating areasonable approximation of a shared realitybetween the server and clients as a problem ofreplication.

That is, a problem of determining a set of data andcommands that flow between the client and serverin order to achieve that approximate shared reality.“

- Tim Sweeney, Epic Games Inc.

Network

• generalized client-server model• authoritative server (dedicated, listen)

• predicting and simulating clients

• “hybrid” code• client and server execute same code on approximately the

same data• minimizes traffic

Network (Cont.)

• generalized client-server model• decoupling of network and game logic facilitates

extensibility• network code can coordinate any game which can be described

by the language

• network is controlled on language level through keywords & variables

• low level network (serialization, reliable UDP) done by core

Network - Basic Terminology

• Actor• object that can move and interact with other actors

• Level• object which contains a set of actors

• Game State• the complete set of all actors that exist in a level

• the current values of all actor variables

Network – Update Loop

1. if (server)Send(Gamestate) to all clients

2. if (client)Send(RequestedMovement) to serverReceive(Gamestate) from serverRender(ApproximateWorldView) to screen

3. if (server || client)Tick(DeltaTime) to update Gamestate

Update(Actors)Execute(Physics)Receive(GameEvents)Execute(ScriptCode)

Actor Roles

• describes how much control the machine (server or client) has over an actor

• controls the actors function call permissions

// Net variables.

enum ENetRole

{

ROLE_None, // No role at all.

ROLE_SimulatedProxy, // Locally simulated proxy of this actor.

ROLE_AutonomousProxy, // Locally autonomous proxy of this actor.

ROLE_Authority, // Authoritative control over the actor.

};

var ENetRole RemoteRole, Role;

Source: Actor.uc.

Bandwidth Optimization: Actor Relevancy

• eight prioritized rules:• not relevant, if (RemoteRole == none)

• determined by the relevancy of its base, if any

• relevant if (bAlwaysRelevant)

• only potentially relevant to the client who owns that Actor if (bOnlyRelevantToOwner)

Bandwidth Optimization: Actor Relevancy

• eight prioritized rules:• relevant if (Owner==Player)

• not relevant if• (bHidden) &&

• (!bBlockPlayers) &&

• (AmbientSound == none)

• relevant if visible according to a line-of-sight check between the actor's Location and the player's Location

• relevant, if was visible less than 2 to 10 seconds ago

Bandwidth Optimization: Prioritization

• Actor::NetPriority• regulates share of the bandwidth based on how

important the Actor is to gameplay

• always relative to all other Actors’ NetPriority

Replication

• Actor replication• only Location, Rotation valid on spawn

• variable replication• regulated by condition in Class Replication Statement

• server to client only

• always reliable

• subject to bandwidth optimization

• repnotify keyword

replication

{

// replicate if server

if (Role == ROLE_Authority && (bNetInitial || bNetDirty))

Armor, Range, AttackDamage;

}

Source: HWPawn.uc.

Where‘s Waldo?simulated event ReplicatedEvent(name VarName)

{

if (VarName == 'TeamIndex')

{

ChangeColor(TeamIndex);

}

}

Source: HWSelectable.uc, before January 11, 2011.

Where‘s Waldo?simulated event ReplicatedEvent(name VarName)

{

if (VarName == 'TeamIndex')

{

ChangeColor(TeamIndex);

}

else

{

super.ReplicatedEvent(VarName);

}

}

Source: HWSelectable.uc.

Gotcha!

Never forget super calls whenoverloading engine class functions!

60 / 58

Replication

• function call replication• keywords:

• server, client

• reliable, unreliable

• server -> client: only to client who owns that Actor

• client -> server: only on owned Actor

• immediately sent, disregarding bandwidth

reliable server function ServerIssueAbilityOrder(HWAIController C, HWAbility Ability, HWSelectable Target)

Source: HWPlayerController.uc.

Go ahead, …

… make somethingUnreal!

References

• Epic Games. UDK Unreal Developer’s Kit. http://www.unrealengine.com/udk/, October 2013.

• Epic Games. UDN Technical Home. http://udn.epicgames.com/Three/TechnicalHome.html, October 2013.

• Epic Games. UDN UnrealScript Language Reference.http://udn.epicgames.com/Three/UnrealScriptReference.html, October 2013.

• Epic Games. UDN AI & Navigation. http://udn.epicgames.com/Three/ReplicationHome.html, October 2013.

• Epic Games. UDN Networking & Replication. http://udn.epicgames.com/Three/ReplicationHome.html, October 2013.

• Epic Games. Epic Games Community Forum. http://forums.epicgames.com/forums/366-UDK, October 2013.

63 / 58

Thank you for your attention!

Contact

Mail

dev@npruehs.de

Blog

http://www.npruehs.de

Twitter

@npruehs

Github

https://github.com/npruehs

64 / 58

Recommended