Game Development Community

AiPlayer and the World Editor

by Bill Koons · in Torque Game Engine · 03/16/2005 (4:04 pm) · 4 replies

Does anyone know what needs to be done so that an AiPlayer can be added from the world editor (F4 - World Editor Creator)? I can currently spawn AI from script, but I'd like to be able to place them in the world editor if possible.

#1
03/16/2005 (4:39 pm)
Check out the ai guard unit code snipit thats as close as you'll probably get. I wouldn't get to deep into AI though. I personally am putting it off because I know that i'll buy the AI pack anyway and that will blow away anything (and everything) that I had created.
#2
03/17/2005 (12:56 pm)
It's very easy, actually.

In your AiPlayer datablock definition (playerData), add this field:

category = "AiPlayer";

Now, add these lines to the script where your AiPlayer datablocks are being defined:

function PlayerData::create(%data)
{
   // The mission editor invokes this method when it wants to create
   // an object of the given datablock type.
   %obj = new AiPlayer() {
      dataBlock = %data;
   };
   return %obj;
}

Save everything, open Torque, bring up the World Editor Creator and expand the Shape list. You'll see "AiPlayer" in there, and all PlayerData datablocks where you added the category field will be listed there. Pick one of them and an AiPlayer will be added.

The category field is very usefull to add specialized objects to the editor.
#3
03/18/2005 (3:31 pm)
I'm tyring to do the same for simple objects like a barrel or box. The only part that i'm getting stuck in is in the following line.

%obj = new somthinggoeshere() {

I don't know what to put for the new statement. I tired Misc thinking that it will show up under the Shapes/Misc. What should I use here?
#4
03/18/2005 (9:42 pm)
Manoel: Thanks so much. Worked great!