IGDA Unity SIG II AI in Unity Emil AngryAnt Johansen Unity - - PowerPoint PPT Presentation

igda unity sig ii
SMART_READER_LITE
LIVE PREVIEW

IGDA Unity SIG II AI in Unity Emil AngryAnt Johansen Unity - - PowerPoint PPT Presentation

IGDA Unity SIG II AI in Unity Emil AngryAnt Johansen Unity Technologies AI in Unity Sensors Decision logic Navigation Sensors Active "Passive" Message driven Second pass filtering Additional sensors or inclusion areas


slide-1
SLIDE 1

IGDA Unity SIG II

AI in Unity

Emil “AngryAnt” Johansen Unity Technologies

slide-2
SLIDE 2

AI in Unity

Sensors Decision logic Navigation

slide-3
SLIDE 3

Sensors

Active "Passive" Message driven Second pass filtering Additional sensors or inclusion areas

slide-4
SLIDE 4

Active

Using Physics.OverlapSphere Iterating list of target objects

slide-5
SLIDE 5

Using Physics.OverlapSphere

Entities already represented in the physics simulation Filter by layer mask Cheap radius check Manual physics checks are expensive

slide-6
SLIDE 6

Manual physics checks are expensive

Do not check each frame Regular physics run at a fixed framerate of 20 fps per default Adapt polling frequency to when the data is

  • needed. Setting up the sensor as a service

for the behaviour logic to use is a good best practice

slide-7
SLIDE 7

Iterating list of target objects

Central registry Objects of interest register with a singleton OnEnable and unregister OnDisable Sensors filter through this list when needed Registry can do early sorting and grouping based on meta data Object.GetObjectsOfType

slide-8
SLIDE 8

“Passive”

Using physics triggers The physics simulation is running anyway, being clever about polling and prediction Requires either extra manual setup of the transform tree or initialization work You are served the data whether you need it or not Use layer filtering via the layer mask table or Physics.IgnoreCollision Most likely need to forward collision information from a child GO to the central sensor logic Radar structure

slide-9
SLIDE 9

Message driven

Central monitor Polling and interpreting state changes on monitored subjects Redirection of messages from clients Relative broadcast Using active sensor to determine target audience Transmitting messages to each member

slide-10
SLIDE 10

Second-pass filtering

Limit object list based on meta data Tag filtering - more expensive than layer mask, but operating on already filtered data set Component based sorting - GetComponent

slide-11
SLIDE 11

Second-pass filtering

Visibility cone

Vector3.Angle ( transform.forward, targetTransform.position - transform.position ) < coneAngle * 0.5f

slide-12
SLIDE 12

Additional filters or inclusion areas

Proximity overriding visibility cone "Audio" / event sensor Crowd influence - dispersal and relaxation

slide-13
SLIDE 13

Decision logic

Whatever is wrong with a bunch of nested if-statements? Useful state machine setups Available middleware

slide-14
SLIDE 14

Whatever is wrong with a bunch of nested if-statements?

It is just logic after all Systems handle abstraction and help keep you sane Does the term "spaghetti code" mean anything to you?

slide-15
SLIDE 15

Useful state machine setups

FSM combines state tracking and handling Simple to understand system Very slim implementation

slide-16
SLIDE 16

Example:

enum + switch in AI update + function call

slide-17
SLIDE 17

Example:

enum + delegate + dictionary in abstract class

slide-18
SLIDE 18

Available middleware

Why? Additional abstraction. Shortens the distance between idea and implementation PlayMaker [video] Behave [demo]

slide-19
SLIDE 19
slide-20
SLIDE 20

Demo: Behave

slide-21
SLIDE 21

Navigation

Setting up simple pathes Available middleware

slide-22
SLIDE 22

Setting up simple pathes

Linking transforms via linked list of node components Keep track of next node Adjust force or direction vector to fit - slerp Basic steering

slide-23
SLIDE 23

Available middleware

Aron Grandberg "A * Pathfinding" Path UnitySteer