Intro to AI STRIPS Planning & Applications in Video-games Lecture1-Part1
Kismet Ai Part1
-
Upload
danish-zariff -
Category
Documents
-
view
237 -
download
0
Transcript of Kismet Ai Part1
-
7/30/2019 Kismet Ai Part1
1/10
UDK tutorials
How to develop bot AI with Kismet
Part 1 - MovementIn the following tutorial I will show how to create a decent AI for a bot putting some Kismet nodestogether.
I assume you are familiar with the basic UDK procedures. The pictures should help you following.
Let's begin.
The first step is to create a room to test the behavior of our bot.
Create a 2048*2048 room with walls and lights.
Add a "screen wall" on one side as the picture below.
Add aNote behind the screen wall selecting it from Content Browser ---> Actor Classes, and a
Player Startclose to the opposite wall (right mouse button on the floor ---> Add Actor ---> Add
Player Start).
UDK Tutorial by C. Scolastici 1 [email protected]
-
7/30/2019 Kismet Ai Part1
2/10
Build all and save. This will be our basic testing room.
Now that the setup is complete, we can spawn a bot.
Open the Kismet window, press the right mouse button on the gray area and select New Action --->
Actor ---> Actor Factory.
With theNote selected in the room, scroll theActor Factory properties, find Spawn Points and click
on the green arrow to add theNote as the Spawn Pointfor theActor Factory.
Then set theFactory property on UTActorFactoryAI, thePawn Classproperty on UTPawn and flag
the Give Default Inventory option.
Don't put anything in Controller Class!
UDK Tutorial by C. Scolastici 2 [email protected]
-
7/30/2019 Kismet Ai Part1
3/10
Now let's make our bot move around the room withPathnodes.
Close the Kismet window and go back to the room.
Add aPathnode (right mouse button on the floor ---> Add Actor ---> Add Pathnode) anywhere
around the center of the room and make sure that it looks towards the Player Startactor. Better not
give your back to enemies!
Before we can tell the bot to move to its destination we need to solve a problem.
Bots cannot reach aPathnode if there is no clear path between the starting position and thedestination (A Pylon would help here, but we are not using Pylons and Navigation Meshes ).
Due to the wall that screens thePathnode in the center of the room from theNote (which is the
spawning point of theActor Factory), we need an extraPathnode to create a clear path between the
starting position of the bot and its destination.
Add a secondPathnode so to have a "joint" between theNote and thePathnode in the center of the
room.
The picture should help you understand what I mean.
Now that we have a clear path we can tell the bot to reach its destination.
Open Kismet, press the right mouse button on the gray area and select New Action ---> AI --->
Move To Actor.
With thePathnode in the center of the map selected, scroll theMove To Actornode properties in the
Properties Window in Kismet, findDestination and click on the green arrow to add thePathnode as
the destination of theMove To Actor.
UDK Tutorial by C. Scolastici 3 [email protected]
-
7/30/2019 Kismet Ai Part1
4/10
Next we need to tell Kismet who's going to move. In the Kismet window, right click on the
Spawnedoutput of theActor Factory node and select Create New Object Variable.
Then connect it to the Targetinput of theMove To Actornode.
Now connect theFinishedslot of theActor Factory with theIn slot of theMove To Actor.
To have this sequence start we then need to set a starting event. Right click on the gray area and
selectNew Event ---> Level Loaded. Then connect theLoaded and Visible slot with the Spawn
Actorslot on theActor Factory.Let's also tell our bot to look at the player while moving. Right click on the gray area and select
New Variable ---> Player ---> Player, then un-flag theAll Playersproperty in the Properties
Window.
Connect the newly created variable (namedPlayer 0) to theLook Atinput of theMove To Actor
node.
The sequence should look like the following.
UDK Tutorial by C. Scolastici 4 [email protected]
-
7/30/2019 Kismet Ai Part1
5/10
Now that the sequence is complete, we are going to test it. Close the Kismet window, go to View
menu and select World Properties. In Game Type find Game Type For PIEand select UTGame. If
you don't, no UTPawn can be spawned!
If you haven't done it yet, build geometry, lighting and paths. Save the project and then launch it.
The bot should come out from behind the screen wall and move to the destination in the center of
the room, looking at the player.
If you try and delete the jointPathnode that we put close to theNote, you'll see that the bot can't
reach its destination and doesn't come out of the screen wall at all.
UDK Tutorial by C. Scolastici 5 [email protected]
-
7/30/2019 Kismet Ai Part1
6/10
Now that we have a moving pawn we can add some spice to its behavior. But first we need to
improve our room.
Create 3 covers in the room for the pawn to hide behind and add a newPathnodebehind each cover.
The following picture should show what I mean.
Build everything up, save and then open the Kismet window. We are going to tell the bot to move to
a random pickedPathnode.
Delete theMove To Actornode, we will set a different one for this.
Right click on the gray area and select New Action ---> Object List ---> Access Object List.
Right click on the Object Listinput on theAccess Object Listnode and select Create New Object
List Variable.
Go back to the room and select the 3Pathnodesbehind the covers, then right click on the Object
List Variable in the Kismet window and selectInsert Selected Actors Into Object List.
You should get something like this.
UDK Tutorial by C. Scolastici 6 [email protected]
-
7/30/2019 Kismet Ai Part1
7/10
Right click on the Output Objectoutput onAccess Object Listand select Create New Object
Variable.
Create a newMove To Actornode and connect itsIn slot with the Outslot ofAccess Object List.
Connect theDestination input (onMove To Actor) to the Output Object Variable on Access Object
List.
Connect the Object Variable on the Spawnedoutput of theActor Factory to the Targetinput on
Move to Actorand also connect thePlayer0 Object Variable to theLookAtinput onMove To Actor.Then connect theFinishedslot on theActor Factory to theRandom slot on theAccess Object List
node and the job is done!
Check the picture for clues.
Test the game several times. You'll see that the bot picks a new destination with every repetition,
thus allowing its actions to be less predictable.
Keep notice that the bot is able to get to those destinations as long as they are "in sight" of the first
Pathnode just outside the screen wall. So always put attention when placing Pathnodes in your
maps and be sure to create clear paths for your bots!
UDK Tutorial by C. Scolastici 7 [email protected]
-
7/30/2019 Kismet Ai Part1
8/10
In the second part of the tutorial we will tell our bot to shoot to the player. But before that I would
like to add a little improvement to the behavior of the bot: we'll have it switching between covers
whenever it sustains damage.
Right click on the gray area in the Kismet window and select New Event ---> Actor ---> Take
Damage.
Right click again and select New Action ---> Event ---> Attach To Event.Connect theFinishedslot on theActor Factory node to theIn slot on theAttach To Eventnode.
Then connect the (red)Eventslot ofAttach To Eventto Take Damage and theAttachee slot to the
Object Variable that instantiate the bot.
Check the pictures to be sure things have been done right.
UDK Tutorial by C. Scolastici 8 [email protected]
-
7/30/2019 Kismet Ai Part1
9/10
We also need to set some parameters of the Take Damage node. Select it and then scroll the
properties in theProperties Window.
In the Seq Event Take Damage section setDamage Tresholdto 0, so that the event will be trigger
no matter the damage sustained by the bot.
Then in the Sequence Event section setMax Trigger Countto 0, too. This way the event will be
triggered again and again at will.
UDK Tutorial by C. Scolastici 9 [email protected]
-
7/30/2019 Kismet Ai Part1
10/10
To complete the sequence, connect the Outslot on the Take Damage node to theRandom slot on the
Access Object Listnode. The idea is to repeat the cycle every time the bot is hit: upon being
damaged, the bot picks a new randomPathnode from the list and moves there.
The final sequence should look like the one in the picture.
We're done! Now the bot changes its position when hit, moving to a different cover.
To be honest, we have an issue here. It may happen that the bot, after taking damage, randomly
picks thePathnode it already lies on, thus not moving at all.
You can try to solve this problem yourselves. Be creative!
UDK Tutorial by C. Scolastici 10 [email protected]