Vehicle AI
by Daniel Neilsen · in Torque Game Engine · 05/08/2002 (1:15 pm) · 82 replies
Hey guys,
Just wondering if anyone out there has done anything in relation to vehicle ai?
Has anyone tried to get this working?
When I try and give my bots commands to move (my bots are hover vehicles) the dont seem to wanna go anywhere :/
Anyone had any luck with this?
Just wondering if anyone out there has done anything in relation to vehicle ai?
Has anyone tried to get this working?
When I try and give my bots commands to move (my bots are hover vehicles) the dont seem to wanna go anywhere :/
Anyone had any luck with this?
About the author
#22
06/14/2003 (1:05 am)
that function was never there, I had to add it to access the protected member .. just a simple wrapper function that returns the exhisting variable.Quote:so again i'll state :
1.) you need to access the mSteering value in Vehicle class
#23
08/27/2003 (1:36 pm)
Hmm... Has anyone considered doing a "Vehicle Remote Control"? I mean instead of using the AIPlayer class, just a special set of functions that move the vehicle from point A to point B (without the need for a bot inside..) ? I ask because that's probably a lot cheaper on CPU time..
#24
I Placed the code at the AIPlayer.cc file but several errors popped. Could someone please guide me where to put what ?
TIA
04/28/2004 (6:36 pm)
Guys,I Placed the code at the AIPlayer.cc file but several errors popped. Could someone please guide me where to put what ?
TIA
#25
04/29/2004 (10:57 am)
Hey Bruno have you gotten it to work yet? I think i will give this a try.
#26
I can help you a bit but first please re-read the entire post that includes the code.
you will notice that I state:
if you still have issues after that please post the First Error your compiler gives you. and we will work thru that.
04/29/2004 (11:56 am)
Bruno, I can help you a bit but first please re-read the entire post that includes the code.
you will notice that I state:
Quote:so again i'll state :find that and read all around it.
1.) you need to access the mSteering value in Vehicle class
2.) you need the function extractEuler(..); search engine for it.
3.) you need a couple class var's I used:
if you still have issues after that please post the First Error your compiler gives you. and we will work thru that.
#27
As I told you in my email, I'm not fluent in C++ ( although I do pretty good in C ).
1) mSteering value in Vehicle class is of Point2F type the new mSteering is of an Enum DrivingState type. I don't know what you mean by "access the mSteering value" should there be another vehicle class that inherits from vehicle where mSteering is redifined ? How do I access values from other classes ? would it be something like
if ( isMounted(this) )
mLastSteered = this.getTheSteeringValueFromTheVehicle(this);
mSteered = something else;
2) I copied the extractEuler function from the WorldEditor.cc. placed the prototype on the AiPlayer.h and the function body on AiPlayer.cc
this issue seems to be solved at least.
3) you used mAvoidObject for instance. I searched thru the engine project and couldn't find it. I don't have a clue of where it should be created, what should it's type be, should it be public or private, what is it's default value when constructing the class, etc.
TIA
04/29/2004 (12:51 pm)
Hi Badguy,As I told you in my email, I'm not fluent in C++ ( although I do pretty good in C ).
1) mSteering value in Vehicle class is of Point2F type the new mSteering is of an Enum DrivingState type. I don't know what you mean by "access the mSteering value" should there be another vehicle class that inherits from vehicle where mSteering is redifined ? How do I access values from other classes ? would it be something like
if ( isMounted(this) )
mLastSteered = this.getTheSteeringValueFromTheVehicle(this);
mSteered = something else;
2) I copied the extractEuler function from the WorldEditor.cc. placed the prototype on the AiPlayer.h and the function body on AiPlayer.cc
this issue seems to be solved at least.
3) you used mAvoidObject for instance. I searched thru the engine project and couldn't find it. I don't have a clue of where it should be created, what should it's type be, should it be public or private, what is it's default value when constructing the class, etc.
TIA
#28
heh dont mind the null response to the email.
I dont check it much. better off catching me here.
you simply need to go to the vehicle class
and add a function :
Point2F getSteering(){return mSteer;}
that should be close paste that in the Vehicle class make it public
mSteer might not be correct name check the header for the correct name.
as for the mAvoidObject
that is a class variable I used in my AIPlayer
simply remove the reference to it
Or implement it.. it would be a private class variable
I would export it to the script and use the script to identify when he needs to avoid something.
I would just remove it to keep this simple for now.
04/29/2004 (12:57 pm)
Ok cool..heh dont mind the null response to the email.
I dont check it much. better off catching me here.
you simply need to go to the vehicle class
and add a function :
Point2F getSteering(){return mSteer;}
that should be close paste that in the Vehicle class make it public
mSteer might not be correct name check the header for the correct name.
as for the mAvoidObject
that is a class variable I used in my AIPlayer
simply remove the reference to it
Or implement it.. it would be a private class variable
I would export it to the script and use the script to identify when he needs to avoid something.
I would just remove it to keep this simple for now.
#29
It compiled ok but still didn't work. The bot just drives away with the car instead of following the path.
Here is what I did.
Added the getSteering() function to the vehicle class : added a prototype in Vehicle.h and a Point2F Vehicle::getSteering() at the end of vehicle.cc.
Copy the enum mSteering and mLastSteered to the AIPlayer class.
I created locals mAvoidObjects and mAvoidLocation. Set mAvoidObject to 0 in order to maintain the code for later implementation.
Inserted the 3rd part of the code inside AIPlayer::getAIMove. BUT :
My AIPlayer doesn't have a ModeReverse enum or an mCanDrive variable so I nopped the part of the if where it tests it and set the movePtr->y to 1 ( since there is no ModeReverse).
Should I put the rest of the function on an else for ismounted() ?
How can I echo something to the console to test if this part of the function is being called ?
04/29/2004 (1:45 pm)
Ok,It compiled ok but still didn't work. The bot just drives away with the car instead of following the path.
Here is what I did.
Added the getSteering() function to the vehicle class : added a prototype in Vehicle.h and a Point2F Vehicle::getSteering() at the end of vehicle.cc.
Copy the enum mSteering and mLastSteered to the AIPlayer class.
I created locals mAvoidObjects and mAvoidLocation. Set mAvoidObject to 0 in order to maintain the code for later implementation.
Inserted the 3rd part of the code inside AIPlayer::getAIMove. BUT :
My AIPlayer doesn't have a ModeReverse enum or an mCanDrive variable so I nopped the part of the if where it tests it and set the movePtr->y to 1 ( since there is no ModeReverse).
Should I put the rest of the function on an else for ismounted() ?
How can I echo something to the console to test if this part of the function is being called ?
#30
If so feel free to use ctrl-F10
that is Debug to Line
so select the line of code you want to stop and and press that.
Or add break points.
there is an echo commented out in the getSteeringAngle() function
uncomment that and you should see it spam the console with values as he drives.
04/29/2004 (1:53 pm)
Bruno are you using visual studio?If so feel free to use ctrl-F10
that is Debug to Line
so select the line of code you want to stop and and press that.
Or add break points.
there is an echo commented out in the getSteeringAngle() function
uncomment that and you should see it spam the console with values as he drives.
#31
I putted the rest of the function on an else for the isMounted.
The code shows some effect now. But the bot often drives in reverse ?!
This seems strange since I don't have that reverse enum option.
But LOTS OF THANKS for the help. I'll play with it now from here. Next week I'll probably try to add the 3d movement for my crow bots so I think I'll bother you again then.
Best Regards
Bruno
04/29/2004 (3:55 pm)
No, I'm using XCode ( mac ).I putted the rest of the function on an else for the isMounted.
The code shows some effect now. But the bot often drives in reverse ?!
This seems strange since I don't have that reverse enum option.
But LOTS OF THANKS for the help. I'll play with it now from here. Next week I'll probably try to add the 3d movement for my crow bots so I think I'll bother you again then.
Best Regards
Bruno
#33
I'm back from my 3D steering adventures. Still needing some guidance.
I made a copy of getSteeringAngle, called getSteeringPitch. But I don't know if I got it right or if I SNAFU everything.It doesnt seem to be the same as steering in 2D. I don't know how to deal with the roll and it still goes backwards.
I placed copy of the game ( it's basically the tutorial base with some extra scripts ) together with the modifications in AiPlayer and Vehicles in
www.bluefox.trix.net/torque
If you could check it I would be very gratefull.
Bruno
05/02/2004 (4:10 pm)
Hi Badguy,I'm back from my 3D steering adventures. Still needing some guidance.
I made a copy of getSteeringAngle, called getSteeringPitch. But I don't know if I got it right or if I SNAFU everything.It doesnt seem to be the same as steering in 2D. I don't know how to deal with the roll and it still goes backwards.
I placed copy of the game ( it's basically the tutorial base with some extra scripts ) together with the modifications in AiPlayer and Vehicles in
www.bluefox.trix.net/torque
If you could check it I would be very gratefull.
Bruno
#34
05/04/2004 (7:15 am)
Hello Bruno and Badguy. I am also currently working on this. I am attempting to take a different approach. I am trying to create an AIVehicle class using the AIPlayer code. This is so that I don't have to worry about mounting and unmounting player bots.
#35
05/04/2004 (8:09 am)
Before i undertake the task of creating a new class, do you know of any good resources on mounting a bot onto a vehicle?
#36
05/04/2004 (8:58 am)
Bruno, I would like to help get your code working, because I too am trying to accomplish a vehicle controlled by AI. But, I am still trying to figure out the most basic part of scripting a bot to mount a vehicle and begin driving. You mentioned that you have a bot driving your vehicle right now, but it doesn't go in the direction you want. Could you please post how I would go about mounting my bot onto my vehicle? I am using a modified version of the codesampler tutorial base. Thank you.
#37
mounting a bot is simple.
if you can locate my vehicle resource (very old)
it shows you how to mount a character.
it is the same for a bot the only difference is you have to get him to find the vehicle first.
Bruno:
handling altitude can be done a couple different ways.
First of all that algorythm would need to be adjusted as the triangle is for calculating left or right if you setup the triangle to use the top or bottom of the vehicle you should be able to apply that formula.
you will want to fix the backwards thing.
heh have you tried inverting the values?
there must be something up with the move you apply.
movePtr->y = mMoveState == ModeReverse ? -1 : 1;
without reverse you should simply set movePtr->y to 1.
I would forgo the roll for now and just have pitch and yaw do all the work. once that is sweet go and tweak some roll logic in there.
I'll check that out when I get home.
05/04/2004 (8:58 am)
Ryan:mounting a bot is simple.
if you can locate my vehicle resource (very old)
it shows you how to mount a character.
it is the same for a bot the only difference is you have to get him to find the vehicle first.
Bruno:
handling altitude can be done a couple different ways.
First of all that algorythm would need to be adjusted as the triangle is for calculating left or right if you setup the triangle to use the top or bottom of the vehicle you should be able to apply that formula.
you will want to fix the backwards thing.
heh have you tried inverting the values?
there must be something up with the move you apply.
movePtr->y = mMoveState == ModeReverse ? -1 : 1;
without reverse you should simply set movePtr->y to 1.
I would forgo the roll for now and just have pitch and yaw do all the work. once that is sweet go and tweak some roll logic in there.
I'll check that out when I get home.
#38
In that URL I posted is the modified tutorial base I am using. inside there is a script called SuperBomb.cs that mounts a whatever colides with it with a vehicle. You may choose between a car or a flying drone. check also vehicle.cs and car.cs.
Don't try to make an AIVehicle class. The problem with the steering doesn't seem to be an AI problem, it's more about how to handle the physics of the vehicle. Mounting the bot to it ( or dismounting is not really a problem ).
Other approach I'm considering is modifying the PLAYER class. Not AIPlayer, but the Player itself, that has the onMove method. This will let both me and my bots to fly wherever they want.
Badguy.
That movePtr->y line was one of the first ones I checked since ModeReverse wasn't defined in the AIPlayer Enum's I don't really know why it still backs up. I uploaded everything at www.bluefox.trix.net/torque in case you'd like to give a look.
TIA
Bruno
05/04/2004 (2:54 pm)
Ryan,In that URL I posted is the modified tutorial base I am using. inside there is a script called SuperBomb.cs that mounts a whatever colides with it with a vehicle. You may choose between a car or a flying drone. check also vehicle.cs and car.cs.
Don't try to make an AIVehicle class. The problem with the steering doesn't seem to be an AI problem, it's more about how to handle the physics of the vehicle. Mounting the bot to it ( or dismounting is not really a problem ).
Other approach I'm considering is modifying the PLAYER class. Not AIPlayer, but the Player itself, that has the onMove method. This will let both me and my bots to fly wherever they want.
Badguy.
That movePtr->y line was one of the first ones I checked since ModeReverse wasn't defined in the AIPlayer Enum's I don't really know why it still backs up. I uploaded everything at www.bluefox.trix.net/torque in case you'd like to give a look.
TIA
Bruno
#39
front.y=box.max.y; // should be true for all these objects
this assumes the positive y is the front of the vehicle.
in torque if you exported this object with the pivot set correctly
this will be true.
however if you have not exported the pivot facing the correct way
this will Not be true.
So this brings me to the question:
what model are we using ? is this a custom model?
05/04/2004 (3:33 pm)
Ok one other thing note :front.y=box.max.y; // should be true for all these objects
this assumes the positive y is the front of the vehicle.
in torque if you exported this object with the pivot set correctly
this will be true.
however if you have not exported the pivot facing the correct way
this will Not be true.
So this brings me to the question:
what model are we using ? is this a custom model?
Torque Owner Alex \"bathala\" Rufon
I tried applying the code posted here into the game I'm making and there seems to be something missing.
I basically can't find the getSteering() function used here:
I always merge my code with the latest HEAD ... did something change?
Thanks.
Alex
edit: some spelling errors