Important UDK Classes How they fit together Copyright © 2015 – Curt Hill.

34
Important UDK Classes How they fit together Copyright © 2015 – Curt Hill

Transcript of Important UDK Classes How they fit together Copyright © 2015 – Curt Hill.

Page 1: Important UDK Classes How they fit together Copyright © 2015 – Curt Hill.

Important UDK Classes

How they fit together

Copyright © 2015 – Curt Hill

Page 2: Important UDK Classes How they fit together Copyright © 2015 – Curt Hill.

Copyright © 2015 – Curt Hill

Introduction• We have created a level• We have seen an introduction to

UnrealScript• We should have also set

several .ini files• We should have also created

several UnrealScript classes descended from:– GameInfo– Pawn– Controller

Page 3: Important UDK Classes How they fit together Copyright © 2015 – Curt Hill.

Classes• There are several classes that are

vital to your play• These include:

– WorldInfo– GameInfo– Actor– Pawn– Controller – Camera

• Understanding how these interrelate is crucial

Copyright © 2015 – Curt Hill

Page 4: Important UDK Classes How they fit together Copyright © 2015 – Curt Hill.

WorldInfo• This is the master class for the

engine– We will use this to find out or change

the world in our programs

• Source is in:…\Development\Src\Engine\Classes

• It has instance variables that control:– Lighting, physics, sounds among

othersCopyright © 2015 – Curt Hill

Page 5: Important UDK Classes How they fit together Copyright © 2015 – Curt Hill.

Functions• GetWorldInfo will return a WorldInfo

object• Several iterators:

– AllControllers– AllPawns

• Several events– PostBeginPlay– PreBeginPlay

• It is unlikely but possible we will make a descendant of WorldInfo

Copyright © 2015 – Curt Hill

Page 6: Important UDK Classes How they fit together Copyright © 2015 – Curt Hill.

WorldInfo and GameInfo

• One of the most important objects of WorldInfo is GameInfo

• The instance variable of type GameInfo is named Game– Since UnrealScript is polymorphic it

may be any descendant of GameInfo

• This is actually set in the Editor– Among other possible places

Copyright © 2015 – Curt Hill

Page 7: Important UDK Classes How they fit together Copyright © 2015 – Curt Hill.

Menu• The descendent of GameInfo that is

actually part of the WorldInfo is set from the editor– Use the View and World menu

• This is connected to an individual level

• The Game Type is the set of values which are known descendants– A drop down

• It is also dependent on the ancestry of the GameInfo item you choose

Copyright © 2015 – Curt Hill

Page 8: Important UDK Classes How they fit together Copyright © 2015 – Curt Hill.

View/World

Copyright © 2015 – Curt Hill

Page 9: Important UDK Classes How they fit together Copyright © 2015 – Curt Hill.

GameInfo

• Determines the rules and characteristics of this game

• This will determine several things in the game– Presence or absence of the pawn– First or third person camera– Heads Up Display

• Next are four displays with different GameInfos

Copyright © 2015 – Curt Hill

Page 10: Important UDK Classes How they fit together Copyright © 2015 – Curt Hill.

GameInfo

Copyright © 2015 – Curt Hill

Page 11: Important UDK Classes How they fit together Copyright © 2015 – Curt Hill.

CloudGame

Copyright © 2015 – Curt Hill

Page 12: Important UDK Classes How they fit together Copyright © 2015 – Curt Hill.

UTTeamGame

Copyright © 2015 – Curt Hill

Page 13: Important UDK Classes How they fit together Copyright © 2015 – Curt Hill.

UTDeathMatch

Copyright © 2015 – Curt Hill

Page 14: Important UDK Classes How they fit together Copyright © 2015 – Curt Hill.

GameInfo Descendents

Copyright © 2015 – Curt Hill

Page 15: Important UDK Classes How they fit together Copyright © 2015 – Curt Hill.

More on GameInfo

• There will only be one GameInfo (or descendant) instance

• Chosen before the level starts and persists for the rest of gameplay for that level– If the level is terminated and a new

level entered a different GameInfo is used

• This class does delegate some of its duties to other classes

Copyright © 2015 – Curt Hill

Page 16: Important UDK Classes How they fit together Copyright © 2015 – Curt Hill.

Continuing

• GameInfo also selects the player classes

• It specifies the default pawn, camera and controller class

• In this and other ways it is the central class for determining what game play will be like

Copyright © 2015 – Curt Hill

Page 17: Important UDK Classes How they fit together Copyright © 2015 – Curt Hill.

Actors

• Recall that an actor is anything with a representation in the level

• This includes– Static meshes– Lights– Sounds– Pawns

Copyright © 2015 – Curt Hill

Page 18: Important UDK Classes How they fit together Copyright © 2015 – Curt Hill.

Actor Events

• Destroyed()• Falling ()• RanInto (Actor Other)

– Actor ran into another actor

• TakeDamage and Tick will be considered later

Copyright © 2015 – Curt Hill

Page 19: Important UDK Classes How they fit together Copyright © 2015 – Curt Hill.

More Events• Bump (Actor Other,

PrimitiveComponent OtherComp, Object.Vector HitNormal)– Somebody bumped me

• HitWall ( Object.Vector HitNormal, Actor Wall, PrimitiveComponent WallComp)

Copyright © 2015 – Curt Hill

Page 20: Important UDK Classes How they fit together Copyright © 2015 – Curt Hill.

TakeDamage

• When a pawn or actor is damaged this event is called

• It may be used to modify the damage– Such as when armor is present

• It may also be called to inflict damage

Copyright © 2015 – Curt Hill

Page 21: Important UDK Classes How they fit together Copyright © 2015 – Curt Hill.

TakeDamage• Signature:event TakeDamage ( int Damage, Controller InstigatedBy, Object.Vector HitLocation, Object.Vector Momentum, class<DamageType> DamageType, optional Actor.TraceHitInfo  HitInfo, optional Actor DamageCauser)

Copyright © 2015 – Curt Hill

Page 22: Important UDK Classes How they fit together Copyright © 2015 – Curt Hill.

Tick(float delta)

• An event in any actor• Parameter is time since last call• Called so many times per second• Allows animation and AI• Usually want this to be quick if the

actor is not active– Like: if(somebool) return

Copyright © 2015 – Curt Hill

Page 23: Important UDK Classes How they fit together Copyright © 2015 – Curt Hill.

Actor Methods

• Destroy()– Makes it die

• Move (Vector)– Moves in this direction– Usually invoked in Tick so motion may

be dependent on timing

• TakeRadiusDamage– Wrapper for TakeDamage

Copyright © 2015 – Curt Hill

Page 24: Important UDK Classes How they fit together Copyright © 2015 – Curt Hill.

The Player

• Any player uses a set of several classes to function

• These are:– Controller– Pawn– Camera

• We now consider these

Copyright © 2015 – Curt Hill

Page 25: Important UDK Classes How they fit together Copyright © 2015 – Curt Hill.

Pawn

• Controls the presence of the player in the level

• A player does not need a pawn, but if they lack one they can move around but not be seen

• Pawn is a derivation of Actor• URL:

http://wiki.beyondunreal.com/UE3:Pawn_(UDK)http://wiki.beyondunreal.com/UE3:Pawn_%28UDK%29

Copyright © 2015 – Curt Hill

Page 26: Important UDK Classes How they fit together Copyright © 2015 – Curt Hill.

Pawn Properties

• Float Alertness in the range -1 to 1• bool bLOSHearing • bool bMuffledHearing• bool bCanCrouch • Controller Controller • SkeletalMeshComponent Mesh• Weapon Weapon

Copyright © 2015 – Curt Hill

Page 27: Important UDK Classes How they fit together Copyright © 2015 – Curt Hill.

Pawn Events

• BreathTimer()• OutsideWorldBounds()

– Max is 524286 uu

• PostBeginPlay()• PreBeginPlay()• SetWalking(bool iswalking)

Copyright © 2015 – Curt Hill

Page 28: Important UDK Classes How they fit together Copyright © 2015 – Curt Hill.

Controller

• The interface between the person and the pawn class

• Interprets the keyboard commands and passes on to the pawn

• Say method takes a string and displays it to the pawn

Copyright © 2015 – Curt Hill

Page 29: Important UDK Classes How they fit together Copyright © 2015 – Curt Hill.

Controller Events

• HearNoise• IsInCombat• Destroyed• SeeMonstrer(Pawn)• SeePlayer(Pawn)• We will look at some of these in

the animation presentation

Copyright © 2015 – Curt Hill

Page 30: Important UDK Classes How they fit together Copyright © 2015 – Curt Hill.

Camera• Generates the display that the

player sees• A first person display has the

camera aligned with the player’s location and orientation

• In third person it usually follows the person around

• For dramatic effect it may leave the player and follow the action somewhere else

Copyright © 2015 – Curt Hill

Page 31: Important UDK Classes How they fit together Copyright © 2015 – Curt Hill.

Startup

• When the game starts WorldInfo is initialized

• The first piece of code that you might get to see is the GameInfo init() method

• There are also the Post and Pre Begins of the various actors

Copyright © 2015 – Curt Hill

Page 32: Important UDK Classes How they fit together Copyright © 2015 – Curt Hill.

Logging• The debugging process is

somewhat hard• One of the tricks we use is logging• Every time the editor (which is an

extension of the game) starts it keeps a log

• It closes that log when done• This log is UDKGame\Logs and is

Launch.log• In this we may write messages

Copyright © 2015 – Curt Hill

Page 33: Important UDK Classes How they fit together Copyright © 2015 – Curt Hill.

Log Macro

• The command is a macro• Part of the preprocessor• The simplest form is just to take a

string– Make the string say all that you need

• Example:`log(“*** Damage ”$DamageAmount);

Copyright © 2015 – Curt Hill

Page 34: Important UDK Classes How they fit together Copyright © 2015 – Curt Hill.

Finally

• We have the fundamentals for putting actors into motion and making them active agents

• We now need an example to see it all come together

Copyright © 2015 – Curt Hill