FollowPath for non-Player Bot
by Norv Brooks · in Technical Issues · 06/21/2006 (11:49 pm) · 4 replies
I worked through the bot tutorials of Kevin Harris based on "tutorial.base" mod shipped with TGE and was abled to get the bots to work, follow a path and take damage from the rocket launcher. Then I started trying to get an aircraft non-player bot to fly a path in the same "tutorial.base" mod. I was able to get my bot to "spawnOnPath as far as the x & y axis but not z. My acircraft bot is partly below ground level whereas the path is above the ground a ways. (see screenshot below). Also, the aircraft bot just keeps going back and forth between 2 points not 4. I've also included part of the code from my file aircraft.cs and a modified bot.cs from "tutorial.base". Can anyone help, please!
[image] http://members.dslextreme.com/users/vronsoftware/twinotter.jpg [/image]
[image] http://members.dslextreme.com/users/vronsoftware/twinotter.jpg [/image]
[b]aircraft.cs[/b]
// Load dts shapes and merge animations
datablock TSShapeConstructor(TwinOtter_rootDts)
{
baseShape = "~/data/shapes/aircraft/TwinOtter.dts";
sequence0 = "~/data/shapes/aircraft/TwinOtter_root.dsq";
};
datablock PlayerData(AircraftShape)
{
renderFirstPerson = false;
shapeFile = "~/data/shapes/aircraft/twinotter.dts";
scale = ".5 .5 .5";
//className = Armor;
};
// AircraftShape Datablock methods
function AircraftShape::onAdd(%this,%obj)
{
// Called when the PlayerData datablock is first 'read' by the engine (executable)
parent::onAdd(%this, %obj);
}
[b]bot.cs[/b]
//--------------------------------------------------------------
datablock PlayerData( TOBot : AircraftShape )
{
// TO DO: Add extra stuff here to manage new A.I. functionality...
patrol = true;
attack = false;
};
function TOBot::onReachDestination( %this, %obj ) [b]// function not changed[/b]
function TOBot::onEndOfPath( %this, %obj, %path )
{
%obj.nextTask();
}
//-----------------------------------------------------------------------------
// AIPlayer static functions [b]basically left as was[/b]
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
// AIManager static functions
//-----------------------------------------------------------------------------
function AIManager::think( %this ) // function not changed
function AIManager::spawn(%this, %num)
{
%spawnName = "TOBot" @ %num;
%pathName = "MissionGroup/TwinOtterPath";
%nodeNum = %pathName.getCount() % %pathName.getCount();
%player = AIPlayer::spawnOnPath(%spawnName, %pathName);//, %num % 4);
%player.path = %pathName;
%player.currentNode = %nodeNum;
%player.targetNode = (%nodeNum < 3) ? %nodeNum + 1 : 0;
%player.followPath(%pathName, -1);
%this.player[%num] = %player;
}About the author
#3
Thanks a lot for your help!
Norv
06/22/2006 (5:00 pm)
Bruno - the resource you referred was real good and I have my aircraft in the air now. However, I thought I would be able to figure out where the function MountVechicle should go, but I don't seem to be doing it right. I can get it called but then I get en error that "onMountVechile(%targetObject.getDataBlock(), %obj,%targetObject); can be found. Where does that function come from?Thanks a lot for your help!
Norv
#4
06/23/2006 (6:38 am)
You're using tutorial.base. Starter.fps or racing examples will probably have a .cs file with that function in it.
Torque Owner Mike Rowley
Mike Rowley
members.dslextreme.com/users/vronsoftware/TwinOtter.jpg
As for your spawn in problem, I don't know.
edit: img tags not working?