Game Development Community

dev|Pro Game Development Curriculum

AIWheeledVehicle2

by Brian McGavin · 10/16/2005 (12:32 am) · 35 comments

Download Code File

AIWheeled vehicle was an outstanding resource. I have done some work to improve the steering and speed control. In this resource I have made a new class called AIWheeledVehicle2, and I have added an example mission that will make a robot car that drives around the starter.racing track.

This resource is made for Torque v1.4 and works with starter.racing example
You need to do the following once you download the zip file.

1. Add AIWheeledVehicle2.h and AIWheeledVehicle2.cc to your project.
2. Add carbot.cs to your server script folder
3. Add robotracing.mis to your data/missions folder
4. Modify the file game.cs in your server script folder
add the line
exec("./carbot.cs");
after the line
exec("./checkpoint.cs");

add the lines in 'function startGame()'
//Robot car
$Bot1 = CreateAIWheeledVehicle2("Herbie","CarPath",pickSpawnPoint());
MissionCleanup.Add($Bot1);
echo("Bot id: " @ $Bot1);

after
if ($Game::Running) {
error("startGame: End the game first!");
return;
}

add the lines in the 'function startRace()'

$Bot1.followPath("CarPath", -1);
$Bot1.lap = -1;
$Bot1.nextCheck = 1;

before the lines
// Start the game timer
// if ($Game::Duration)
// $Game::Schedule = schedule($Game::Duration * 1000, 0, "onGameDurationEnd" );
$Game::Running = true;

$Game::Running = true;

5. Run the starter.racing game and choose robotracing.mis


How it works.
You need to create a path for the vehicle to follow in your mission. You also need to add a dynamic field 'speed' at each path point. You will want to set smaller speed values for sharp turns and bigger ones for straightways. It will require some trial and error to tweak it right. The path you create needs to be a drivable path.

The vehicle will try to follow the 'racing line' you draw. The farther the vehicle gets from the racing line the sharper the turn.

About the author

Recent Blogs

Page«First 1 2 Next»
#21
12/19/2005 (1:25 am)
#22
12/19/2005 (1:30 pm)
@Juan
Yahoo has been marking some emails incorrectly as spam. Sorry if I haven't responded to your email. I sent you a new email.
#23
12/20/2005 (4:10 am)
#24
04/19/2006 (12:14 pm)
@ Denis


How did you get your vehicles to follow the path perfectly? I cant get them to follow it hardly at all. Even with the vehicles slowed way down they barely follow the path. Setting the move tolerance very low has no effect either. They miss the nodes by a mile and still continue on to the next one.



@ Legend Studios

Is there some point to editing all your posts? It's hard for others to learn from your questions when we dont even know what your questions were. I find this practice to be very annoying and I'm sure others do also.
#25
07/11/2006 (2:54 am)
I've followed this all through, the vehicle is spawned but nothing happens with "Herbie". No console errors.
Any ideas?
#26
08/16/2006 (3:58 am)
@Gonzo

Sorry for answering few months later but i just didn't have time for playing with torque.
I changed job, place of living so i was really stuck for past few months.

I am on work right now but when i arrive home i can take a look in scripts to tell you excactly what i did (it was all scripting anyway) and level design helped a lot cos that cars are racing in narrow canyon.

Also i remember that i had to change speed variable on different nodes on car path, increase mass of vehicle and something else but don't quite remember right now (i will check out if u still need that ).

However i do remeber that it took me 2 weeks of tweaking car script + part of the level where cars are racing :)
#27
09/09/2006 (8:04 pm)
I just wanted to say this resource is a great one... I will be using a modifed version of this in a Prototype DWI Learning Game/Simulation. Brian, you saved me many hours of scripting and coding. The Mission file was great to include since it saved time in test the code and script changes I had to make.

Thank you, Thank you.

Would you be interesting in consulting on my project? Your background might be of value to my game. Either way... this is one of the better resources on the forums. GG should add this one into the racing.starter demo.
#28
09/20/2006 (1:23 pm)
This is great, worked just as advertised. This should be added to Torque 1.5!
#29
10/10/2006 (7:09 am)
How to say the bot drove 2 laps?
#30
07/17/2007 (10:55 am)
Any hint on how to get my AiWheeled vehicles deleted when they reach their last path node.
Again, thank you for this awsome resource.
#31
01/27/2008 (8:58 pm)
Hey Brian. Thanks for the resourse, but when I add the AiWheeledVehicle2.cc and AiWheeledVehicle2.h files to the project and then recompile torque, if compiles fine. When I open up torque game engine though, it is saying that there is no such thing as an AiWheeledVehicle2 datablock.

Please Help Me. :(
#32
06/22/2008 (3:31 am)
I have so much trouble getting the vehicles to follow the paths. It's just random. Most of the time the vehicle doesn't know they have just rolled over the node and think they are lost so they zoom off and try to approach it again.

Anyone know how to fix this?
#33
10/05/2008 (1:48 pm)
have you tried with TGEA ? .

i add the files, buts i have this error

Register object failed for object (null) of class AIWheeledVehicle2.
#34
10/18/2008 (7:22 pm)
this resource works only with the previous resource configuration .
http://www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=6222

...
// If we're not being controlled by a client, let the // AI sub-module get a chance at producing a move. Move aiMove(NullMove); if (!move && isServerObject() && getAIMove(&aiMove)) move = &aiMove;

...
#35
12/18/2008 (12:42 am)
hey brain i followed all your procedure for aiwheeledvehicle2, but im not getting any new default car other than our default car in the game. and there is no movement of vehicle through the path u given. could u help me out to make a car to run on the paths......

waiting for reply
Page«First 1 2 Next»