63
Introduction to the Unreal Development Kit (UDK) Nick Prühs October 23, 2013

Introduction to the Unreal Development Kit

Embed Size (px)

DESCRIPTION

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

Citation preview

Page 1: Introduction to the Unreal Development Kit

Introduction to the Unreal Development Kit (UDK)

Nick Prühs

October 23, 2013

Page 2: Introduction to the Unreal Development Kit

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

Page 3: Introduction to the Unreal Development Kit

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)

Page 4: Introduction to the Unreal Development Kit

Features (Cont.)

• gorgeous cinematics (Mantinee)

• terrain

• built-in networking

• real-time shaders

• broad audio support

• particle effects (Cascade)

Page 5: Introduction to the Unreal Development Kit

Features (Cont.)

• artificial intelligence

• distributed computing (Swarm)

• descructible environments

• Bink video codec

• SpeedTree foliage editor

• FaceFX facial animation

• Scaleform 4.0 UI

Page 6: Introduction to the Unreal Development Kit

Platforms

Page 7: Introduction to the Unreal Development Kit

Platforms

Page 8: Introduction to the Unreal Development Kit

Platforms

Page 9: Introduction to the Unreal Development Kit

Integrated Partners

Page 10: Introduction to the Unreal Development Kit

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

Page 11: Introduction to the Unreal Development Kit

Useful Stuff

• UT Source Code

• UDK Forums

• Showcases

• UDK Programming Home

• UDK Gems

• UnrealScript Language Reference

Page 12: Introduction to the Unreal Development Kit

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

Page 13: Introduction to the Unreal Development Kit

Unreal Engine Basics

• Core• C++

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

• Virtual Machine• runs in core

• executes UnrealScript

Page 14: Introduction to the Unreal Development Kit

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"

Page 15: Introduction to the Unreal Development Kit

Class Hierarchy

Page 16: Introduction to the Unreal Development Kit

UnrealScript Features

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

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

• iterators• Actor.AllActors

• Actor.DynamicActors

• Actor.CollidingActors

Page 17: Introduction to the Unreal Development Kit

UnrealScript Features (Cont.)

• statesstate Dead

{

ignores SeePlayer, HearNoise, KilledBy, NextWeapon, PrevWeapon;

function bool IsDead()

{

return true;

}

// ...

}

Source: PlayerController.uc

Page 18: Introduction to the Unreal Development Kit

UnrealScript Features (Cont.)

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

Source: DefaultInput.ini

Page 19: Introduction to the Unreal Development Kit

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

Page 20: Introduction to the Unreal Development Kit

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

Page 21: Introduction to the Unreal Development Kit

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

Page 22: Introduction to the Unreal Development Kit

UnrealScript Features (Cont.)

• localization filesclass HWAbility extends Actor

config(HostileWorldsAbilityData)

abstract;

/** The name of this ability. */

var localized string AbilityName;

Source: HWAbility.uc

Page 23: Introduction to the Unreal Development Kit

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

Page 24: Introduction to the Unreal Development Kit

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

Page 25: Introduction to the Unreal Development Kit

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

Page 26: Introduction to the Unreal Development Kit

Navigation Meshes (Cont.)

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

Page 27: Introduction to the Unreal Development Kit

Navigation Meshes (Cont.)

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

Page 28: Introduction to the Unreal Development Kit

Navigation Meshes (Cont.)

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

Page 29: Introduction to the Unreal Development Kit

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

Page 30: Introduction to the Unreal Development Kit

Navigation Meshes

DEMO

Page 31: Introduction to the Unreal Development Kit

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

Page 32: Introduction to the Unreal Development Kit

Benefits of Navigation Meshes (Cont.)

• handling of dynamic objects

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

Page 33: Introduction to the Unreal Development Kit

Benefits of Navigation Meshes (Cont.)

• handling of dynamic objects

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

Page 34: Introduction to the Unreal Development Kit

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

Page 35: Introduction to the Unreal Development Kit

Weapon Fire

Page 36: Introduction to the Unreal Development Kit

Weapon Fire (Cont.)

Page 37: Introduction to the Unreal Development Kit

Weapon Fire (Cont.)

Page 38: Introduction to the Unreal Development Kit

Weapon Fire (Cont.)

Page 39: Introduction to the Unreal Development Kit

Weapon Fire (Cont.)

Page 40: Introduction to the Unreal Development Kit

Weapon Fire (Cont.)

Page 41: Introduction to the Unreal Development Kit

Weapon Fire (Cont.)

Page 42: Introduction to the Unreal Development Kit

Weapon Fire (Cont.)

Page 43: Introduction to the Unreal Development Kit

Weapon Fire (Cont.)

Page 44: Introduction to the Unreal Development Kit

Weapon Fire (Cont.)

Page 45: Introduction to the Unreal Development Kit

Weapon Fire (Cont.)

Page 46: Introduction to the Unreal Development Kit

Weapon Fire (Cont.)

Page 47: Introduction to the Unreal Development Kit

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.

Page 48: Introduction to the Unreal Development Kit

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

Page 49: Introduction to the Unreal Development Kit

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

Page 50: Introduction to the Unreal Development Kit

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

Page 51: Introduction to the Unreal Development Kit

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)

Page 52: Introduction to the Unreal Development Kit

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.

Page 53: Introduction to the Unreal Development Kit

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)

Page 54: Introduction to the Unreal Development Kit

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

Page 55: Introduction to the Unreal Development Kit

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

Page 56: Introduction to the Unreal Development Kit

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.

Page 57: Introduction to the Unreal Development Kit

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

{

if (VarName == 'TeamIndex')

{

ChangeColor(TeamIndex);

}

}

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

Page 58: Introduction to the Unreal Development Kit

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

{

if (VarName == 'TeamIndex')

{

ChangeColor(TeamIndex);

}

else

{

super.ReplicatedEvent(VarName);

}

}

Source: HWSelectable.uc.

Page 59: Introduction to the Unreal Development Kit

Gotcha!

Never forget super calls whenoverloading engine class functions!

60 / 58

Page 60: Introduction to the Unreal Development Kit

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.

Page 61: Introduction to the Unreal Development Kit

Go ahead, …

… make somethingUnreal!

Page 62: Introduction to the Unreal Development Kit

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

Page 63: Introduction to the Unreal Development Kit

Thank you for your attention!

Contact

Mail

[email protected]

Blog

http://www.npruehs.de

Twitter

@npruehs

Github

https://github.com/npruehs

64 / 58