Game Development Community

Ai

by Bryan Rayner · in Torque Game Engine · 06/02/2006 (9:26 am) · 3 replies

Is there a starting tutorial on how AI works in Torque? It seems complicated, and it shouldn't be...

#1
06/02/2006 (9:38 am)
TDN Article on AI

I'm not sure of your experience level, but AI can be EXTREMELY confusing and frustrating for new developers. It is not as simple as many people think. Kind of like advanced physics isn't nearly as simple as people like to pretend.
#2
06/02/2006 (11:03 am)
Well, in the games I've already made (no Torque) the AI players were just a child of the player class, and I added the AI command codes in to run at every step.

But looking at torque (can't even get a DTS in, stupid me - probably the chemo) there are alot of seperate classes just for AI. That stuff is really confusing to me, I think that it should be easier than that.

I guess that when Torque was made for tribes 2, it wasn't made to be an engine meant for etitability. Tribes 2 didn't even have good AI (so I've heard)

Oh well. I guess I will learn all this new stuff sooner or later. (hope for sooner)
#3
06/02/2006 (12:22 pm)
Hey Bryan,

It took me a while to get the idea of torque AI also, but I think I have my arms wraped around it for the most part now. As you said in some other engine you used AI players were just children of the player class, then AI command codes were hooked onto the new AI player body to make it preform whatever function that may be needed. Torque actually runs that way, just hard to realise at a first glance.

At the top of my aiPlayer.cs there is this block of code to define the new AI player body off of the standard user controled player.

datablock PlayerData(DemoPlayer : PlayerBody)
{
   shootingDelay = 2000;
};

That small block of code takes the PlayerBody and all of it's variables, and pretty much just duplicates its self with the new name DemoPlayer that is used for the AI players.

Then a little further on theres the spawn function for the AI player, shown here.

function AIPlayer::spawn(%name,%spawnPoint)
{
   // Create the demo player object
   %player = new AiPlayer() {
      dataBlock = DemoPlayer;
      path = "";
   };
   MissionCleanup.add(%player);
   %player.setShapeName(%name);
   %player.setTransform(%spawnPoint);
   return %player;
}

In this block of code it defines the DemoPlayer datablock for the AIplayers, then just a few commands that pull their info out of vars for the name, spawn point, etc.

This is just a very small portion of the basics of torque AI, but none the less I hope it helps you understand a little better.

-Max