How to implment AI WheeledVehicle in T3D?
by Liew Pak San · in Torque 3D Professional · 10/29/2009 (12:07 pm) · 5 replies
Hi everybody,
I'm still considered noob in T3D and still trying to get the hang of it. I would like to ask how do I port the AIWheeledVehicle class over to T3D?
I have searched through the forum and have find this post, which match to my problem. I have read through the articles and the comments. Been to the link, followed the instruction over there, but was not successful as the cpp code that need to modify is base on TGEA which I can't locate in T3D.
If anyone has been able to port AIWheeledVehicle class over to T3D, would you please guide me how to do it?
Regarding on the following comment found in the first link:
Are there any examples/books that explain using this method in more details?
Thank you in advances.
I'm still considered noob in T3D and still trying to get the hang of it. I would like to ask how do I port the AIWheeledVehicle class over to T3D?
I have searched through the forum and have find this post, which match to my problem. I have read through the articles and the comments. Been to the link, followed the instruction over there, but was not successful as the cpp code that need to modify is base on TGEA which I can't locate in T3D.
If anyone has been able to port AIWheeledVehicle class over to T3D, would you please guide me how to do it?
Regarding on the following comment found in the first link:
Quote:What I meant was creating an AIClient or AIConnection game connection (e.g. with the aiConnect method) and attaching your wheeled vehicle as its control object (using "setControlObject"). Basically, each connection to the server can have an object in the world that it controls. By setting the vehicle as the control object of the AI connection, it will execute the moves queued by the connection.by Rene Damm
Are there any examples/books that explain using this method in more details?
Thank you in advances.
About the author
#2
Thank you for sharing the process with me! Sorry for the late reply.. Yes the AIWheeledVehicle class is working on T3D now. It takes me quite sometime to figure out the engine recompiling portion, still learning. Haha. Really appreciated your help! :)
11/03/2009 (9:21 am)
Hi Marcus,Thank you for sharing the process with me! Sorry for the late reply.. Yes the AIWheeledVehicle class is working on T3D now. It takes me quite sometime to figure out the engine recompiling portion, still learning. Haha. Really appreciated your help! :)
#3
04/18/2014 (8:02 pm)
thank you very much for the sharing. i has long time thinking about the way to implement the ai car,you give me really big bonus. besides,i have met "non-conobject" error and so on , but conquer it at last. thank you again
#4
04/20/2014 (9:37 am)
Great Job thanks Marcus....
#5
To, but not including Sunday, April 20, 2014
Result: 1629 days
It is 1629 days from the start date to the end date, but not including the end date
Or 4 years, 5 months, 17 days excluding the end date
Alternative time units
1629 days can be converted to one of these units:
140,745,600 seconds
2,345,760 minutes
39,096 hours
1629 days
232 weeks (rounded down)
I think we've gone a wee bit too far with that thread necro there...
04/20/2014 (12:23 pm)
From and including: Tuesday, November 3, 2009To, but not including Sunday, April 20, 2014
Result: 1629 days
It is 1629 days from the start date to the end date, but not including the end date
Or 4 years, 5 months, 17 days excluding the end date
Alternative time units
1629 days can be converted to one of these units:
140,745,600 seconds
2,345,760 minutes
39,096 hours
1629 days
232 weeks (rounded down)
I think we've gone a wee bit too far with that thread necro there...
Torque 3D Owner Marcus L
just follow the instructions except from the things i have listed below:
1. In "engine/sources/T3D/vehicles/vehicle.h", since void renderMountedImage(SceneState *state, RenderInst *ri); is removed, you should put this line virtual bool getAIMove(Move* move); under bool collidingWithWater( Point3F &waterHeight ); instead.
2. when you download aiWheeledVehicle.cpp you have to change all the "mAtan"s to "mAtan2", and you have to change all the "isZero"s to "mIsZero".
3. assuming that you don't have aiWheeledVehicle.cs, just use this:
function CreateAIWheeledVehicle(%name, %botPath) { // Create the A.I. driven bot object... %player = new AIWheeledVehicle() { dataBlock = %db; path = %botPath; }; MissionCleanup.add( %player ); %player.setShapeName( %name ); %node = %botPath.getObject(0); %player.setTransform( %node.getTransform()); %player.curentNode = 0; // current node %player.setMoveSpeed(1.5); %player.setMoveTolerance(5.0); %player.score = 0; return %player; } function AIWheeledVehicle::followPath( %this, %path, %node ) { // Start the bot following a path %this.stopThread(0); // Make sure our path is valid if( !isObject( %path ) ) { echo( "AIWheeledVehicle::followPath failed - Bad Path!" ); %this.path = ""; return; } // How far do we want to travel on the path? if(( %node > %path.getCount() - 1 ) || (%node == -1)) %this.targetNode = %path.getCount() - 1; else %this.targetNode = %node; if( %this.path $= %path ) { %this.moveToNode(%this.currentNode + 1); } else { %this.path = %path; %this.moveToNode(0); %this.currentNode = 0; } } function AIWheeledVehicle::moveToNextNode( %this ) { if( %this.targetNode < 0 || %this.currentNode < %this.targetNode ) { if( %this.currentNode < %this.path.getCount() - 1 ) %this.moveToNode( %this.currentNode + 1 ); else %this.moveToNode( 0 ); } else { if( %this.currentNode == 0 ) %this.moveToNode( %this.path.getCount() - 1 ); else %this.moveToNode( %this.currentNode - 1 ); } } function AIWheeledVehicle::moveToNode( %this, %index ) { // Move to the given path node index %this.currentNode = %index; %node = %this.path.getObject(%index); %this.setMoveDestination( %node.getTransform(), %index == %this.targetNode ); } /// /// Default car callbacks! /// function DefaultCar::onReachDestination( %this, %obj ) { // Moves to the next node on the path. if( %obj.path !$= "" ) { if( %obj.currentNode == %obj.targetNode ) %this.onEndOfPath( %obj, %obj.path ); else %obj.moveToNextNode(); } else echo( "AIWheeledVehicle::onReachDestination warning - Path is blank!" ); } function DefaultCar::onEndOfPath( %this, %obj, %path ) { %obj.moveToNode(1); //%obj.nextTask(); %obj.nextTask(); }Now just make a path, write "CreateAIWheeledVehicle(%name, %botPath)" in the console and "car.followPath(%path,-1)"...