Welcome, Guest. Please Login or Register
  (UTC)
AvP Unknown
News:
Normal Topic AI - How to move from point A to B (Read 3580 times)
Ras
Spawnkiller
*
Offline



Posts: 40
Joined: Jun 12th, 2010
Gender: Male
AI - How to move from point A to B
Jun 12th, 2010 at 11:18pm
Print Post Print Post  
In this tutorial I will, assuming you have prior knowledge of DEdit and know how to build a basic room with lighting and a seal, demonstrate how to make your desired AI character move from A to B.

----------------------------------------------------------
Well first, right-click and press the 'add object' option.

Select the 'AI Node' entity and place it where you want your AI to move, name it 'node1' or anything else, doesn't really matter - be sure to keep it near the ground or nearby a wall IF it is for an alien, keep it 32 units off from the wall and disable 'move to ground' if this is what you are going for, otherwise leave the object's properties alone.

Create the AI, call him ai_bob or something to your amusement.

For this I'm going to use a human character, if you are using an alien and want him to run up a wall then make sure the node is at the point on the wall you want him to go to, and move to ground is not true.

Now before we do any scripting you must make a special brush bound to an object, select the 'AI' texture in the WorldTexture folder (none of the sub-directory folders) and create a brush, make sure it is taller than your AI and if it's for a wallwalking alien make sure the brush extends up a good deal higher than the node placed on the wall, make sure it covers your AI and the length he must travel to get to the node - bind it to the AI volume object and make sure it touches the ground and stretches out a wee bit further than the AI (to give him some leg room).

This allows the AI to navigate, the AI volume brush works like a guide for the AI's pathing and where they are placed (although not necessary, each of your individual volume brushes should be bound to seperate volume objects!) is where their navigation meshes will be placed and, ultimately, will allow them to navigate.

Now make a trigger / switch, which ever one tickles your fancy and in the properties (for triggers it will be the 'targets' button and in the string field titled TargetName1 write 'ai_bob', or whatever name you gave your AI - for switches it will be the 'OnTriggerTarget' box, write 'ai_bob' or the name you decided for it within the stringbox.)

Now before we make the script check your AI volume and AI itself, now select either the trigger or switch, whatever one you decided upon, and select the (for triggers Targets >> MessageName1 stringbox) or the OnTriggerTarget >> OnTriggerMessage (for switches) stringbox and write:

Code
Select All
scr (mt node1); 



This translates into "AI_Bob, perform the action 'moveto node1 and stop', this could be made more complex by using the follow path command and having multiple nodes to navigate through, but for me to go through that would mean to stray away from the specific aim of this tutorial.

Alternately if you write in the 'Target' box of either the trigger or switch '[NULL]' and then in the 'Message' field the following:

Code
Select All
msg ai_bob scr (mt node1); 



This will tell the the engine to send a 'message (msg)' input to 'ai_bob' that he should 'priority script (scr)' the action 'move-to (mt)' 'node1 (the ai node object)' - although either method will suffice.

You may now process your map, walk into the trigger or press the switch that you've created and watch your AI move from his starting position to his node point.




I may expand upon this and write some more complex examples of AI movement, but this tutorial alone should provide you with a strong view on how the system works - have fun now!


-Rasirez
« Last Edit: Jun 12th, 2010 at 11:21pm by Ras »  
Back to top
 
IP Logged