Вы находитесь на странице: 1из 5

BASIC KISMET AI

This tutorial will go over the basics of path animation in UT3. After doing this tutorial, you will understand how to get character objects, aka enemies, to look like they are interacting with your player character, or get them to do a specific animation. The next path AI tutorial will show you how to get the characters to actually do a specific animation while following the path animation and interacting with your player. This tutorial assumes you understand how to use the UT3 engine to build basic levels and understand how to use the Kismet editor. The idea you get from this tutorial should be: Now that I can make a character in the game do animations based on my scripting, I can now set up different sequences that can be used for gameplay like in Rainbow 6 Vegas. For examplewhen you are in single player mode and you give one of your AI teammates a command to do something like look under the doorhe will walk up to it, bend down, and play the look under door animation. Its been a while since Ive played the game and I cant remember what happens after that, but lets say, if he sees a bad guy, he shouts, We have 2 bogies in sight. This is all from the basic path animation scripting. But, again, the NEXT path animation tutorial will teach you how to import and set up custom animation. First off, you need to know the ingredients of this tutorial: 1 Level I used a Subtracted Cube at 1024 x 1024 x 1024. 1 Light to light your level. 1 Player Start Have it aimed toward the middle of your box room. Save your level as DM-levelname The level name is up to you. DM- will give us a HUD and weapons. Create a circle of path nodes around the outer edge of your box level. Do not add a path node where the player start is. A player start is scripted to be a path node as well. To add a path nodeRight Click>Add Actor>Path Node. It will look like an apple. To see your path nodes, lighting, and be able to play test your level, you will have to REBUILD ALL. Then above any viewport (I recommend the TOP) there is a small BLACK ARROW pointing downclick it and select PATHS to see your paths. You can also push P, But I find that using shortcuts in this editor usually causes problems, so I stick to menus.

1 Trigger this trigger will spawn a character to do the path animation. We will spawn (create) the character when the level starts, but we will use the trigger to tell the character when to start doing something.

Now that your level is built, lets get started. This is what my level looks like:

Now that we have a level and understand what we are doing and what we should think about producing after we understand the concepts, we can start scripting. So, here is what we are going to do. First, we are going to state in ENGLISH what we want to do. Then we are going to find a way to do it in KISMET. We want to: Create a character when the level is loaded/started. Have the character do something when we tell him torun around when we hit the trigger. Have the character shoot at usFor example, he will be an enemy waiting around the corner.

Now that we understand in our minds what we want to accomplish, here is the Kismet:

Lets take a closer look: www.dougoberndorf.com/ai1kismetdownload.jpg

On the image you will see from left to right: The event: Level Loaded and Visible o There are other events as wellLevel Beginning, Startup, and Reset. We are choosing the visible one because our character will be waiting around the corner and we do not see him until we get thereso do does not have to spawn at the beginning or startup, we are not resetting the level, and since he does not startup at the beginning, it saves a very, very, very, small number of processing power, but every little bit helps. o Be sure to click on the Level Loaded icon and set the MaxTriggerCount to 1, so it only does this once. What does the event do: New Action>Actor>Actor Factory o This spawns the character. o Ive set the SpawnCount to 1 so we can only create 1 character to manipulate. You can spawn more than 1, but only the first one will use the programing. o Click on the Actor Factory icon and choose a few options. o Click on the blue arrow under Factory to choose ActorFactoryAIthats the one Im using, but you can see that there are a ton of others. I also like UTActorFactoryAI because it has an option to go into default deathmatch mode when the script is over. o The ControllerClass is set to UTBot, so we can controll the character. o Under PawnClass, Ive found that DemoPawn and UTPawn work. o For a SpawnPoint, I just chose one of the Path Nodes. You can either click on one and add it to the SpawnPoints section, or right click on the variable square of the icon and add it there.

o The interesting part is WHAT IS SPAWNED. For that I just have a New Variable>Object>Object. This is just a filler to get the scripting to work. The Actory Factory already knows to spawn a character, but you need an object to tell the script to actually spawn it. I have left it blank (you should get ? marks). And since it is blank, it just spawns a randomly named, regular pawn, nothing special. If you had your own character, you would apply it there. You can also see that we use this icon for all the other actions as well because we need to tell this random pawn to run and shoot and not just stand there. Now that we have a characterwhat do we want to do with him? Well, above we decided to have him run somewhere and then shoot at us. So, lets select the trigger, right click and choose: o New Event Using Trigger>Used. We can use other options, but again, we want the character to come around the corner after we push the button on the console. o New Action>AI>Move to Actor o This is real simpleuse a path node as a Destination, and use the ??? object from earlier as a Target (who is going to the Destination). Hell automatically look where he is going, so dont worry about that. THIS IS THE MOST IMPORTANT PART OF ANY ANIMATION. This tutorial has 11 iconsgo ahead and count them. When the game starts, it only takes something like 0.05 seconds to read it from start to finish, but it takes 0.1 seconds to spawn the character, 1 second to go to path node #1, and another second to go to path node #2, 0.1 seconds to turn toward the player, and as many seconds as you want to shoot at the player. SO, WHAT DOES THIS MEAN??? This means that if you do not time everything right, and you do not give enough time for your actions to take place, either the first one or the last will get played and none of the rest. So, give time for your character to do what needs to be done. o Were just going to give 1 second after this Move to Actor. That should be enough, but your level might be different. o There are 2 ways to do this. I like to right click on the black square next to Finished and SET ACTIVATE DELAY. To get rid of the Delay, just right click again and set it back to Zero. o Another way, which is probably a little more professional and easier to read, is to right click, New Action>Misc>Delay. And then connect everything. We want our character to move to another point now. So copy and paste your Move to Actor, but remember to change to a different path node or your character will not move anywhere. You should also have your delay pasted as well. If you use an actual delay and not the black square short cut, copy/paste it as well. Now for the fun stuff. We want the character to shoot at us!!! o New Action>AI>Start Firing At.

o Most of you probably thinkhes not looking at us, so how will he fire at us? Well, there are ways to make him look at us, but why bother when the Fire At script tells him to look at us. o Again this is a simple connection. The target is again, the ??? object character we created earlier. o Who/what is he firing at? New Variable>Object>Player. o Hmmmmwhat weapon is he firing????? I left this option until now just so you will understand it a little better. Go back to your Actor Factory icon and take a look inside Factory.bGiveDefaultInventorycheck it and 2 lines down give him a weaponor 10! I chose the Link Gun. o Ok, not to get the gun to work. As you know, most guns have 2 firing modes. So you would think that if you go to the Start Firing At icon you will see an option for this. You are correct, but there is a problemForcedFireMode 255?? Yeah, this is a mistake, and no matter what you type in, it stays 255. However, it does remember what you type in. I always mix up the two, but 0 is one firing mode and 1 is another, so type in a 0 or a 1 and see which is which. o Be sure to set a delay, so the character will know when to stop shooting and the scripting will know not to override the action all together. Once you have a delay, right click, New Action>AI>Stop Firing. Again, who will stop firing??? Object from earlier.

Well, thats it. Its pretty simple, so rebuild all and test it out. If it doesnt work, check everything until it does. Again, this is a basic animation tutorial to give you an idea of how you would control an enemy or any other NPC in a game. The next tutorial will teach you how to create custom animations and play them during your actions.

Вам также может понравиться