Random AI model?
by Chris Oconnell · in Torque Game Engine · 02/25/2006 (6:26 pm) · 14 replies
I posted this in another section, but maybe it's better viewed here.
I am trying to utilize many multiple AI enemies in a project (basically based on AIGuard.cs from A3DGPAI1) ...but I don't want them all to look alike. Can anyone tell me or point me to how I would go about modifying my cs file to load a random model from any number of 3 or 4 dts characters?
...or if easier, how to load random skins onto one dts guy?
...Thanks ahead.
I am trying to utilize many multiple AI enemies in a project (basically based on AIGuard.cs from A3DGPAI1) ...but I don't want them all to look alike. Can anyone tell me or point me to how I would go about modifying my cs file to load a random model from any number of 3 or 4 dts characters?
...or if easier, how to load random skins onto one dts guy?
...Thanks ahead.
About the author
#2
If you have 2 models who share the same skeleton you can also inherit on the TSShapeConstructor as well.
02/26/2006 (12:05 am)
You're close but you also need to make sure there is a TSShapeConstructor for each different model used in the game... A TSShapeConstructor ties a model to it's animation sequences you can find an example in example/starter.fps/data/shapes/player/player.csIf you have 2 models who share the same skeleton you can also inherit on the TSShapeConstructor as well.
#3
Thanks
02/26/2006 (7:52 am)
Sorry to step in and ask a diverting question. Is there a difference in methods available in using either scheme above and more than one level? I see this is about meshShape... In the above examples, say the Mosquito object was inherited from the PlayerBody at the very top, making the Snake object two[??] levels below PlayerBody. Would Snake inherit all of the methods of PlayerBody too, or just Mosquito methods? Or would the functions have to be repeated with Mosquito as the object? Or would adding the className variable do the same? This part of datablocks and the className confuses me. This is a good example of basic TorqueScripting I need to know better...it's coming along slowly.Thanks
#4
02/26/2006 (10:41 am)
How do you work a skin into the datablock in the case that you have 1 character with many texture/material sets?
#5
I thank you for this information, I did have a hunch that this was the case, but even with this information I cant get more than one AI (npc) running at the same time. Just defining the playerdata to use (for the shape file) doesn't work, I cant seem to find where to place such things, The code gets confused and replaces the one with the other gives it the wrong name and it doesn't move anymore.
What I am trying to do is:
1. Have more than one NPC (shapes ETC..)
2. Have them each follow there own path
3. Gives each NPC its unique name.
I can't for some reason find how to make the AIplayer recognize unique NPCs. I can only ever get ONE to work, if I add new datablocks like you suggested, the AIplayer.cs gets confused and i'm left with the wrong name over the wrong Shape on the wrong path with the wrong name.
So, can you submit a full AIplayer.cs with more than one NPC. On more than one Path, with more than one Name over there heads..Respectivly?
Thanks.
Side note: I don't need random, I need unique, defined. Shape (unique) + Path (unique) + name (unique) = AIplayer (unique) running around x 1-3 (ETC).
Side note 2: I have successfully changed the shape of the NPC, from the player to a duck. So I understand what is needed for each new NPC (technically) but I can't figure out how to make them have there own path with there own name.
Side Note3: I think it has somthing to do with the name "Demoplayer".... I have even tryed to recreate anything that has that in its datablock with the unique name of the shape datablock... Didnt work.
Side note 4 : i suck at coding lol.
02/26/2006 (11:35 am)
@Faraz Ahmed & DreamerI thank you for this information, I did have a hunch that this was the case, but even with this information I cant get more than one AI (npc) running at the same time. Just defining the playerdata to use (for the shape file) doesn't work, I cant seem to find where to place such things, The code gets confused and replaces the one with the other gives it the wrong name and it doesn't move anymore.
What I am trying to do is:
1. Have more than one NPC (shapes ETC..)
2. Have them each follow there own path
3. Gives each NPC its unique name.
I can't for some reason find how to make the AIplayer recognize unique NPCs. I can only ever get ONE to work, if I add new datablocks like you suggested, the AIplayer.cs gets confused and i'm left with the wrong name over the wrong Shape on the wrong path with the wrong name.
So, can you submit a full AIplayer.cs with more than one NPC. On more than one Path, with more than one Name over there heads..Respectivly?
Thanks.
Side note: I don't need random, I need unique, defined. Shape (unique) + Path (unique) + name (unique) = AIplayer (unique) running around x 1-3 (ETC).
Side note 2: I have successfully changed the shape of the NPC, from the player to a duck. So I understand what is needed for each new NPC (technically) but I can't figure out how to make them have there own path with there own name.
Side Note3: I think it has somthing to do with the name "Demoplayer".... I have even tryed to recreate anything that has that in its datablock with the unique name of the shape datablock... Didnt work.
Side note 4 : i suck at coding lol.
#6
02/26/2006 (11:53 am)
You may want to look at the AIGuard resource (search in the resources)...he has plenty of different AI NPC's working together to play various goal-based scenarios.
#7
02/26/2006 (11:56 am)
I have looked at it, I dont need guard funcitions, i just need the to move and follow a path. They are just enviromental NPC's, such as butterflys and ducks. Dont need all that attacking stuff.
#8
02/26/2006 (11:56 am)
Yes, but you said that you are having problems instantiating more than one. He can instantiate more than one. Therefore, you may want to see how he does it!
#9
I hope thats not the case as i dont compile the engine.
/goes to look
02/26/2006 (11:57 am)
Point taken, so your saying that the stock AIplayer.cs cant do more than one NPC type critter?I hope thats not the case as i dont compile the engine.
/goes to look
#10
02/26/2006 (12:01 pm)
No, I'm not saying that at all! I'm just saying that sometimes looking at similar examples may point to your issue.
#11
But it seems that both the patrol and guard examples in the cs files use only one shape type, the playerbody Data block. There isn't anything in there about using multiple shape files and unique NPC's.
Once I have figured out this issue, I think it would merge with the AIguard resource and I could modify it to make a duck follow some one, but I still have this same issue of non-unique path following , named NPC's...
Thank you for your help, but that didn't solve it.
02/26/2006 (12:14 pm)
Thank you, but like I said, I have looked at it. And I just did again thinking I had missed something.But it seems that both the patrol and guard examples in the cs files use only one shape type, the playerbody Data block. There isn't anything in there about using multiple shape files and unique NPC's.
Once I have figured out this issue, I think it would merge with the AIguard resource and I could modify it to make a duck follow some one, but I still have this same issue of non-unique path following , named NPC's...
Thank you for your help, but that didn't solve it.
#12
http://www.garagegames.com/mg/forums/result.thread.php?qt=18354
02/28/2006 (8:29 am)
I think this post is of intrest to any that are having the same issue. http://www.garagegames.com/mg/forums/result.thread.php?qt=18354
#14
...but I'm a little lost on the method described by Faraz. What syntax do I use to get the getRandom function to call the character datablocks and where do I put it?
I'm not too worried about having TSShapeConstructors for these guys because I'm using mostly Milkshape models. (I know... I know... :P )
03/02/2006 (11:02 pm)
Thanks for all the insight on this and related stuff, guys... ...but I'm a little lost on the method described by Faraz. What syntax do I use to get the getRandom function to call the character datablocks and where do I put it?
I'm not too worried about having TSShapeConstructors for these guys because I'm using mostly Milkshape models. (I know... I know... :P )
Torque 3D Owner Faraz Ahmed
Default Studio Name
In starter.fps the player datablock looks like:
datablock PlayerData(PlayerBody) { ........ shapeFile = "~/data/shapes/player/player.dts"; ......... }(2) A new AIPlayer that looks like the original player can then be created by something like:
.......... new AiPlayer() { dataBlock = PlayerBody; path = ""; }; ............(3) Note the statement above dataBlock = PlayerBody. This is how you assign a description to a new AIPlayer. In this case the player will have a PlayerBody. So, to assign a different type of body to this player you can simply create different datablocks with different shape names:
datablock PlayerData(Troll) { ........ shapeFile = "~/data/shapes/enemies/troll.dts"; ......... } datablock PlayerData(Mosquito) { ........ shapeFile = "~/data/shapes/enemies/mosquito.dts"; ......... } datablock PlayerData(Snake) { ........ shapeFile = "~/data/shapes/enemies/snake.dts"; ......... } new AiPlayer() { dataBlock = Troll; path = ""; }; new AiPlayer() { dataBlock = Mosquito; path = ""; }; new AiPlayer() { dataBlock = Snake; path = ""; };(4) Ideally you dont want to have to write entire datablocks repeatedly so there is a way of copying one datablock into another and changing one item. The code below copies all the information from mosquito into the snake and changes only its shape model:
datablock PlayerData(Mosquito) { ........ ........ shapeFile = "~/data/shapes/enemies/mosquito.dts"; ......... ........ ........ } datablock PlayerData(Snake : Mosquito) { shapeFile = "~/data/shapes/enemies/snake.dts"; }(5) Finally, to randomize your AI enemies you need to make use of the getRandom() function and pass your spawning function a random number based on which you create different enemies using if elses or an array.
Warning: Im a noob, so there may be better ways of achieving the above or I may be flat out wrong :p