CSE4MOD Bot Navigation and Karma Paul Taylor 2009

Preview:

Citation preview

CSE4MODBot 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

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!

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)

Surfaces That Interact

• All surfaces in the Unreal Level have a variable bBlockKarma

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 ??

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

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

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

• 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

• KActorGravScale– Gravity Multiplier per-actor

• KAngularDamping– Rotational Drag

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

• KLinearDamping– Translational Drag

• Kmass– Relative to the volume of the Karma Primitives

• KMaxAngularSpeed– Max speed of actor rotating

• KMaxSpeed– Plain old speed

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

• StayUprightStiffness– Springiness to stay upright

• StayUprightDamping

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

• KImpactThreshold– Calls an event

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

• bKDoConvulsions– Allows RagDolls to convulse! At interval:

• KConvulseSpacing• bRubbery– Makes Ragdolls bend and flex dramatically

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

• 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

Collision Primitives

• MCDBX• MCDSP• MCDCY• MCDCX

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

Viewing Collisions In UnrealEd

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

KHinge

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

Hinges are Triggerable

Ragdolls and Complex Physics

KATThe Karma Authoring Tool

Karma WorkspacesAnd

Karma Assets

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

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

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

Bot.uc

260 Functions24 eventsderives a lot of code from Controller.uc

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)

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.

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

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

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)

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.

Recommended