AI setSkinName: another shortmilemarker for Rex
by Rex · in Torque Game Engine · 12/05/2005 (8:34 am) · 1 replies
Not that many would notice/care: I think I'm starting to understand scripting a bit more now with my being able to specifiy the texture of my AI that spawn from the marker system described in the Mark Holcomb's AIGuard Resource!!!
I'd gotten them to be individually named via a dynamic field in the marker itself, and now I got their setSkinName function working too. It wasn't working at first, because of my time limitations before heading out to work, but after some rest and looking at what I did, I found my error and got it working.
I started with:
I was attempting to just call:
It's great to be an artist and have the engine user friendly enough to be able to do 'simple' things like this....even got crudimentary AI from scripting the Holcomb code, as I have no compiler or experience with that....that has been my greatest triumph yet. I can hear the coder's snickering already...lol. ;) I'd like to be able to specifiy different weapons too, but that will take some tinkering. The Holcomb code has a function dedicated to setting that up and I'm sure it needs to go in there, perhaps??
I'd gotten them to be individually named via a dynamic field in the marker itself, and now I got their setSkinName function working too. It wasn't working at first, because of my time limitations before heading out to work, but after some rest and looking at what I did, I found my error and got it working.
I started with:
//This is the spawn function for the bot.
function AIPlayer::spawn(%name, %obj, %skin)//%skin variable added to get dynamic texture on bot
{
// Create the demo player object AIPlayer();
%player = new AIPlayer() {
dataBlock = DemoPlayer;
//The marker is the AIPlayer marker object that the guard is associated with.
//The marker object is kept with the player data because it's location, and
//dynamic variable values are used in several functions. This also allows the addition
//of future dynamic variables without having to change the spawn/respawn functions to
//access them.
marker = %obj;
botname = %name;
skin = %skin;//new line added to get a dynamic texture on bot
//echo("change skin");
....I was attempting to just call:
%player.setSkinName(%skin)//%skin=dynamic variable in marker, assigned in lines above. This did nothing, whaaaa, until I realized the %player was connected to the %obj variable and then I input this:
%player.setSkinName(%obj.skin);, and it worked!!! When I spawned and flew to each marker's location to see the AI's texture, each was as specified in the marker, Yahoo! I'd forgotten to include it in the respawn function, but after killing a first spawn, the texture reverted back to base.player.png....
It's great to be an artist and have the engine user friendly enough to be able to do 'simple' things like this....even got crudimentary AI from scripting the Holcomb code, as I have no compiler or experience with that....that has been my greatest triumph yet. I can hear the coder's snickering already...lol. ;) I'd like to be able to specifiy different weapons too, but that will take some tinkering. The Holcomb code has a function dedicated to setting that up and I'm sure it needs to go in there, perhaps??
About the author
Rex does all his 3D graphics through BrokeAssGames and is currently working on DSQTweaker, Ecstasy Motion, and other interesting projects yet to be revealed. Just ask him about anything DTS/DSQ related, he's happy to help.
Torque Owner Demolishun
DemolishunConsulting Rocks!
I created a "flag" object and set it up with these textures:
base.flag.png
black.flag.png // same as base
red.flag.png
blue.flag.png
yellow.flag.png
green.flag.png
purple.flag.png
I use this to change flag colors at bases when they are taken over by opposing teams:
These are all the same object, just called setskinname on each with a different color texture.