AI Unit Class Help?
by Kevin Reay · in Torque Game Engine · 04/29/2003 (4:36 pm) · 10 replies
Hey all,
I working on a super-simple single player game to help me learn the ins and outs of the engine. I want to create a bunch of little mindless ai characters that run around. I can do the ai coding easy enough, I'm just wondering where I should put the code for my new characters. I don't really want to use the AIPlayer and the Player class as these seem a little heavy for what I want. (the characters are not like the player) I was wondering, should I make a new AICharacter class that derives from ShapeBase and a AICharacterData from ShapeBaseData to handle the AI and charactor info together?
Any other ideas?
Thanks,
Kevin
I working on a super-simple single player game to help me learn the ins and outs of the engine. I want to create a bunch of little mindless ai characters that run around. I can do the ai coding easy enough, I'm just wondering where I should put the code for my new characters. I don't really want to use the AIPlayer and the Player class as these seem a little heavy for what I want. (the characters are not like the player) I was wondering, should I make a new AICharacter class that derives from ShapeBase and a AICharacterData from ShapeBaseData to handle the AI and charactor info together?
Any other ideas?
Thanks,
Kevin
About the author
#2
it is lighter cause of that.
the only real difference between something you would make and this class would be Animation needs and the use of the Player's Collision methods.
That is what costs this class.(Player the base of AIPlayer)
so if your ai guys dont need animation much or at all
... then it is feasible to do the collision
(which is all you would be left with to get to the state of being ready to use a Shapebase as AI in your new class)
specifically the collision while moving object in scene.
example .. walking him into a building and over the terrain.
So if your ready to put together that collision logic.
and you dont need the animation much or at all I say go for a new class from Shapebase
But if you dont wanna write or wouldnt write it fast enuff..
use the current AI class as your starting point.
04/29/2003 (5:39 pm)
yea AIPlayer doesnt use the GameConnection class anymore.it is lighter cause of that.
the only real difference between something you would make and this class would be Animation needs and the use of the Player's Collision methods.
That is what costs this class.(Player the base of AIPlayer)
so if your ai guys dont need animation much or at all
... then it is feasible to do the collision
(which is all you would be left with to get to the state of being ready to use a Shapebase as AI in your new class)
specifically the collision while moving object in scene.
example .. walking him into a building and over the terrain.
So if your ready to put together that collision logic.
and you dont need the animation much or at all I say go for a new class from Shapebase
But if you dont wanna write or wouldnt write it fast enuff..
use the current AI class as your starting point.
#3
I think that now I'm going to derive from c++ AICharacter for each type of "baddie" in the scripts, for special ai interactions and stuff.
Any more thoughts are welcome.
Thanks,
Kevin
04/29/2003 (5:58 pm)
Ok, thanks. I've decided to to make a new class based on the AIPlayer class called AICharacter, and to leave the player class in use. I just discovered that player douesn't have to be the same as a actual game player, but can have any model, etc.I think that now I'm going to derive from c++ AICharacter for each type of "baddie" in the scripts, for special ai interactions and stuff.
Any more thoughts are welcome.
Thanks,
Kevin
#4
exactly what the sucker was designed to do.
I found the things I needed to complete your goal,
was to create an AIObjective class.
store some stuff there about an obj via the datablocks.
I also created a named group to store them in.
then each ai got a vector of said pointer's.
and I setup script functions to access them.
now it was real easy setting up all kinds of stuff using the script.
Just to give ya a heads up.
One thing about using the Player class as an AI with different model, there are some animations that Must be supported or the engine will crash.
04/29/2003 (6:09 pm)
Good call ... exactly what the sucker was designed to do.
I found the things I needed to complete your goal,
was to create an AIObjective class.
store some stuff there about an obj via the datablocks.
I also created a named group to store them in.
then each ai got a vector of said pointer's.
and I setup script functions to access them.
now it was real easy setting up all kinds of stuff using the script.
Just to give ya a heads up.
One thing about using the Player class as an AI with different model, there are some animations that Must be supported or the engine will crash.
#5
I am currently working on some AI code right now too. What kind of stuff have you accomplished with your objectives Badguy? I'd be interested to see what direction other people have gone with the code.
I mostly am focusing on the pathfinding right now. I should have something nice to show by the middle of next week or so. All my stuff is based off of David Massey's node based pathfinding code.
04/29/2003 (7:24 pm)
You only need one animation for it to work corretly, the "root" animation, which doesnt need to have any motion at all, but it still needs to be there.I am currently working on some AI code right now too. What kind of stuff have you accomplished with your objectives Badguy? I'd be interested to see what direction other people have gone with the code.
I mostly am focusing on the pathfinding right now. I should have something nice to show by the middle of next week or so. All my stuff is based off of David Massey's node based pathfinding code.
#6
Any ideas?
Thanks,
Kevin
04/30/2003 (8:02 am)
Ok, thanks. Now I have another question, this time about the Player class usage. If I derive from the Player class to make my AICharacter class, will the character physical model format have to follow that of the default player. To rephrase, is the model layout of the default player built into the Player class? Because I want to have a simple ai character (a cow) that dousn't have many animations, two legs, torso, etc.Any ideas?
Thanks,
Kevin
#7
04/30/2003 (11:43 am)
I *believe* that you could make the model of a normal player class a cow if you like. I do not think there are any restrictions on the structure of the model. A player model can be human, a cow, an alien, or a rock. It makes no difference to the engine, as long as teh DTS file for the model is exported correctly.
#8
One thing I was wondering is, this changes done to the AIPlayer class, are they in the 1_1_2 or do I have to get a later version ? (cause I'd rather stick to a stable version, for the moment)
05/01/2003 (8:24 am)
I see I am not the only one thinking of having barnyard animals running around, eh :-)One thing I was wondering is, this changes done to the AIPlayer class, are they in the 1_1_2 or do I have to get a later version ? (cause I'd rather stick to a stable version, for the moment)
#9
Basicaly, in game terms this means that AIClient would be useful for a bot in a deathmatch game, since the actual player object would keep dying, but the client would remain, so it could respawn and begin fighting again.
AIPlayer is more useful when you dont need to emulate an actual connection, and instead just want a simple player object. An example of this would be an RPG where the townspeople are NPCs controlled by the AI. There is no need for those to be counted as connections to the server. Also, even though AIPlayer is not derived from gameconnection, it still works fine in multiplayer games.
05/02/2003 (11:42 am)
The architecture of the AI code in torque has changed alot over the prevous versions. In the current HEAD version, AIPlayer is derived from Player, while AIClient is derived from AIConnection, which is derived from GameConnection. AIClient should be used to emulate an actual, human controlled CONNECTION, whereas AIPlayer simply creates a Player object that the AI controls.Basicaly, in game terms this means that AIClient would be useful for a bot in a deathmatch game, since the actual player object would keep dying, but the client would remain, so it could respawn and begin fighting again.
AIPlayer is more useful when you dont need to emulate an actual connection, and instead just want a simple player object. An example of this would be an RPG where the townspeople are NPCs controlled by the AI. There is no need for those to be counted as connections to the server. Also, even though AIPlayer is not derived from gameconnection, it still works fine in multiplayer games.
#10
they do mostly simple stuff..
example : Collect where you pass an object type
in the Objective
and he will find and collect one..
he will use different information for the actual collection
all figured thru the script.
(weapon or vehicle check, available status blea blea blea)
so they can find any game object thru this one ..
be it a vehicle or a weapon or item.
as well attack and chase methods.
and some simple path usage. (not path finding)
you just give him a path name and he will use it.
05/03/2003 (4:52 pm)
Josh : they do mostly simple stuff..
example : Collect where you pass an object type
in the Objective
and he will find and collect one..
he will use different information for the actual collection
all figured thru the script.
(weapon or vehicle check, available status blea blea blea)
so they can find any game object thru this one ..
be it a vehicle or a weapon or item.
as well attack and chase methods.
and some simple path usage. (not path finding)
you just give him a path name and he will use it.
Torque Owner Josh Albrecht
Also, if you are just learning how to use it, I wouldnt worry about making it inefficient right now, just use AIPlayer and get it working. And actually, the AIPlayer is the lighter of the two AI classes (with AIClient being the other), or so I've heard.