Spawn AI on Multiple Paths
by Dre Aldridge · in Torque 3D Professional · 03/31/2011 (1:03 pm) · 5 replies
How do I go about spawning AI on multiple paths? For that matter do I have to spawn AI on paths?
About the author
Currently working on college.
#2
%player = AIPlayer::spawnOnPath("Some Dude","MissionGroup/Paths/MyPath");
in order to have multiple bots on paths. I really need to get better at programming so I can create my own custom code.
Thank you.
04/01/2011 (7:12 am)
Ok, I wasn't sure if it was proper to create multiple lines of %player = AIPlayer::spawnOnPath("Some Dude","MissionGroup/Paths/MyPath");
in order to have multiple bots on paths. I really need to get better at programming so I can create my own custom code.
Thank you.
#3
(Note that this relies on having 10 paths, named "MyPathX", which you might want to change.)
04/01/2011 (9:50 pm)
That can work, but you'd be better served with a for loop, such as:%numberOfBots = 10;
for(%i = 1; %i <= %numberOfBots; %i++)
{
AIPlayer::spawnOnPath("Some Dude " @ %i,"MissionGroup/Paths/MyPath" @ %i);
}Now when you want a different number of bots, just change %numberOfBots!(Note that this relies on having 10 paths, named "MyPathX", which you might want to change.)
#4
04/02/2011 (12:56 pm)
Daniel that is perfect. Thanks for that.
#5
I have two paths named accordingly but the spawns just seem to restack on top of themselves till it causes the system to lock up. I need some way to limit the spawning but what I have tried so far has failed and no clue really what is needed at this point.
04/05/2011 (9:21 am)
Well I have been banging my head against the wall with this. I tried the script you suggested Daniel but it causes multiple bots to only spawn in one spot. I have tried various retoolings of the code to get it to spawn on multiple paths only when there are no bots spawned yet but so far no good.function AIManager::spawn(%this)
{
%numberOfBots = 2;
for(%i = 1; %i <= %numberOfBots; %i++)
{
%player = AIPlayer::spawnOnPath("Shootme"@%i, "MissionGroup/Paths/Path"@%i);
}
if (isObject(%player))
{
%player.followPath("MissionGroup/Paths/Path1", -1);
// slow this sucker down, I'm tired of chasing him!
%player.setMoveSpeed(1);
//%player.mountImage(xxxImage, 0);
//%player.setInventory(xxxAmmo, 1000);
return %player;
}
else
return 0;
}I have two paths named accordingly but the spawns just seem to restack on top of themselves till it causes the system to lock up. I need some way to limit the spawning but what I have tried so far has failed and no clue really what is needed at this point.
Torque Owner Robert Fritzen
Phantom Games Development
To spawn on a path, you'll obviously need a path object, looping or not, it doesn't matter.
Then define it like so:
%player = AIPlayer::spawnOnPath("Some Dude","MissionGroup/Paths/MyPath");
adjust the bot name and Path to fit your needs.