32
CSE4MOD Bot Navigation and Karma Paul Taylor 2009

CSE4MOD Bot Navigation and Karma Paul Taylor 2009

Embed Size (px)

Citation preview

Page 1: CSE4MOD Bot Navigation and Karma Paul Taylor 2009

CSE4MODBot Navigation and Karma

Paul Taylor 2009

Page 2: CSE4MOD Bot Navigation and Karma Paul Taylor 2009

Unreal 4

• For the Next, Next Generation Consoles– Due around 2012

http://arstechnica.com/gaming/news/2008/07/epic-games-unreal-engine-4-ready-in-2012.ars

Page 3: CSE4MOD Bot Navigation and Karma Paul Taylor 2009

Karma

• Karma was the Physics Engine in Unreal.• Used from UT2003 & Unreal Championship • Until UT2K4

• Basically used on all versions of the Unreal 2.x Engine

• As of Unreal3 Karma has been dropped in favour of Ageia’s PhysX– Now owned and hardware supported by

Nvidia!

Page 4: CSE4MOD Bot Navigation and Karma Paul Taylor 2009

Access to Karma

• To use Karma you need to have a special actor– KActor– This class + children can react dynamically with

the environment– In the movement category the Physics property is

set to PHYS_Karma.– How objects react is stored in the KParams

property (in the Karma category)

Page 5: CSE4MOD Bot Navigation and Karma Paul Taylor 2009

Surfaces That Interact

• All surfaces in the Unreal Level have a variable bBlockKarma

Page 6: CSE4MOD Bot Navigation and Karma Paul Taylor 2009

Multiplayer = Failure

• Karma does not replicate.

• The Physics that reacts to your explosions etc, will not replicate as Karma is local only

?? One of the reasons Karma was dropped ??

Page 7: CSE4MOD Bot Navigation and Karma Paul Taylor 2009

Static Mesh Performance

• UseSimpleKaramaCollisions• This is the complicated way to use Karma– You need to have a Collision model for your mesh– Otherwise you set it to false, and Karma will use

every Polygon in your static mesh– = Slow!!!– If you set it to true without a Collision Mesh

Page 8: CSE4MOD Bot Navigation and Karma Paul Taylor 2009

Enabling Karma

• Karma doesn’t get enabled till enough force is applied to an Actor.– This is not a bug, it’s an optimisation feature.

– In Kparams you can alter KStartEnabled

Page 9: CSE4MOD Bot Navigation and Karma Paul Taylor 2009

Karma Parameters

• bDestroyOnWorldPenetrate• bDoSafeTime– Extra safe checks on world penetration

• bHighDetailOnly– Removes actions for lower machines

• bKAllowRotate– Allows z-axis rotation• Only affects actors with KStayUpright set

Page 10: CSE4MOD Bot Navigation and Karma Paul Taylor 2009

• bKDoubleTickRate– Increases the speed + Accuracy of physics

calculations but should be set Uniform to any objects which MAY collide

• bKNonSphericalInertia– Calculate Inertia NOT based on a sphere

• bKStayUpright– Duh! = zAxis

Page 11: CSE4MOD Bot Navigation and Karma Paul Taylor 2009

• KActorGravScale– Gravity Multiplier per-actor

• KAngularDamping– Rotational Drag

• Kboyancy– 0 = ignored– 1 = float mid water– >1 = float to surface

Page 12: CSE4MOD Bot Navigation and Karma Paul Taylor 2009

• KLinearDamping– Translational Drag

• Kmass– Relative to the volume of the Karma Primitives

• KMaxAngularSpeed– Max speed of actor rotating

• KMaxSpeed– Plain old speed

Page 13: CSE4MOD Bot Navigation and Karma Paul Taylor 2009

• KStartAngVel (XYZ)• KStartEnabled• KStartLinVel• KVelDropBelowThreshold– Causes an Event

• StayUprightStiffness– Springiness to stay upright

• StayUprightDamping

Page 14: CSE4MOD Bot Navigation and Karma Paul Taylor 2009

• Kfriction– 1=Full friction– 0 = no friction

• KImpactThreshold– Calls an event

• Krestitution– Bouncyness• 0 = None• 1 = perfect energy retention

Page 15: CSE4MOD Bot Navigation and Karma Paul Taylor 2009

• bKDoConvulsions– Allows RagDolls to convulse! At interval:

• KConvulseSpacing• bRubbery– Makes Ragdolls bend and flex dramatically

• Kskeleton– This sets the ragdoll skeleton to be used.

Page 16: CSE4MOD Bot Navigation and Karma Paul Taylor 2009

• KCOMOffset– Centre of mass offset (XYZ)

• KInertiaTensor– 6 variables, 0 3 and 5 are important• 0 = ease of roll, changes with Kmass and Drawscale• 3 = ease of pitch• 5 = ease of yaw

Page 17: CSE4MOD Bot Navigation and Karma Paul Taylor 2009

Collision Primitives

• MCDBX• MCDSP• MCDCY• MCDCX

Page 18: CSE4MOD Bot Navigation and Karma Paul Taylor 2009

Collision Primitive Prefixes

• MCDBX - Box• MCDSP - Sphere• MCDCY - Cylinder• MCDCX – Convex Mesh

• These will allow a static mesh to be imported with the collision already set

Page 19: CSE4MOD Bot Navigation and Karma Paul Taylor 2009

Viewing Collisions In UnrealEd

Page 20: CSE4MOD Bot Navigation and Karma Paul Taylor 2009

Constraints

• So far we have covered free objects• Constraints will let us tie objects together– The Three Constraint actors– KBSJoint• Ball-Socket Joint

– KConeLimit• This applies to existing joints and seves to limit rotation

– KHinge

Page 21: CSE4MOD Bot Navigation and Karma Paul Taylor 2009

KHinge

• HT_Normal• HT_Springy• HT_Motor• HT_Controlled– Motor + Specified Destination Angle

Hinges are Triggerable

Page 22: CSE4MOD Bot Navigation and Karma Paul Taylor 2009

Ragdolls and Complex Physics

KATThe Karma Authoring Tool

Karma WorkspacesAnd

Karma Assets

Page 23: CSE4MOD Bot Navigation and Karma Paul Taylor 2009

Maya -> KAT -> Unreal

• Objects are created in Maya with Joints– Exported with axTools to the Unreal PSK format

• KAT opens the .PSX and can then be used to create the .KA file.– You must copy the .AK into the KarmaData folder

of UT.– Then set the KSkeleton variable of your object

Page 24: CSE4MOD Bot Navigation and Karma Paul Taylor 2009

Bot Navigation and AI basics

Bots navigate primarily through the Navigation Path network

The engine uses the A* path-finding algorithm to navigate from X to Y

Page 25: CSE4MOD Bot Navigation and Karma Paul Taylor 2009

Storing Paths

LevelInfo class containsvar const NavigationPoint NavigationPointList;

The Bot Brains come from Bot.uc in the UnrealGame Package.

Yes the original Unreal Package (UT). ~c1994TeamAI again from UnrealGame

Page 26: CSE4MOD Bot Navigation and Karma Paul Taylor 2009

Bot.uc

260 Functions24 eventsderives a lot of code from Controller.uc

Page 27: CSE4MOD Bot Navigation and Karma Paul Taylor 2009

Path Colours

• White – Very Wide• Green – Large NPCs• Blue – Cramped decreased game flow• Purple – Lift, Teleporters and Jump Pads• Light Purple – Ladder• Yellow – Forced Paths• Red – Proscribed Paths (Inverse of Forced)

Page 28: CSE4MOD Bot Navigation and Karma Paul Taylor 2009

Order of preference

• Bots will usually take White, then Green, then blue, but the true answer is hidden in the navigation code

• Bots navigate by attaching a cost to every action.– This allows you to entice them into blue paths

with goodies.

Page 29: CSE4MOD Bot Navigation and Karma Paul Taylor 2009

Remember your console!

• Navigation Debuging:ShowDebugViewclass <>ReviewJumpSpots <optional limit>

- Spawns a bot and forces it to attempt various jump types on every jump spot in your level.

Limits:– Transloc– Combo– Jump– LowGrav

Page 30: CSE4MOD Bot Navigation and Karma Paul Taylor 2009

ShowAI – AI debuggingViewBot – cycles botsViewFlag – CTF DebuggingSoakBots – When errors happen bots will pause

the gameRememberspot

Used by showdebug to show a white line directly, and if possible green lines following the navigation points

Page 31: CSE4MOD Bot Navigation and Karma Paul Taylor 2009

Jump Pads and Teleporters

• JumpSpot points act as a Jump Destination, bots will jump TO this point, not from it!– JumpSpot Properties

• bForceDoubleJump• bDodgeUp• bForceDoubleJumping – no check on success of a jump• bNeverImpactJump – disables shield jumping• bNoLowGrav – not used in low G• bOnlyTranslocator• TranslocTargetTag – set a target for using the

TransLocator• TranslocZoffset – Adjusts bot aiming up / down (z)

Page 32: CSE4MOD Bot Navigation and Karma Paul Taylor 2009

Doorways

• The Door actor acts as a navigation point.– If you have a simple actor as your door, you just

need to set bPathColliding to false.